11

I have created a job with the at command on Solaris 10.

It's working now but I want to kill it but I don't know how I can find the job number and how to kill that job or process.

Mateusz Piotrowski
  • 6,087
  • 9
  • 44
  • 71
soField
  • 2,245
  • 9
  • 34
  • 42
  • 2
    First do `man ps`. Read that. Then update your question based on what you read. – S.Lott Dec 01 '09 at 11:42
  • 1
    S.Lott: `at` jobs aren't the same thing as processes though. – Jason Orendorff Dec 01 '09 at 12:02
  • job is running at background , when i run ps -ef i can see some processes running of my commands which my bash script contains that commands , its runnig 15 seconds at once , and proceses ids always changing when i run ps -ef and i could not kill with kill process_id – soField Dec 01 '09 at 12:03
  • what if i restart cron service ? – soField Dec 01 '09 at 12:47

4 Answers4

13

You should be able to find your command with a ps variant like:

ps -ef
ps -fubob # if your job's user ID is bob.

Then, once located, it should be a simple matter to use kill to kill the process (permissions permitting).

If you're talking about getting rid of jobs in the at queue (that aren't running yet), you can use atq to list them and atrm to get rid of them.

paxdiablo
  • 772,407
  • 210
  • 1,477
  • 1,841
  • it s not in queue it s running job every 15 seconds at once – soField Dec 01 '09 at 12:15
  • If you have a process that's kicking on other jobs (new ones every 15 secs), you need to kill the top-level one first, so that behavior stops. That's still using ps to locate it and kill to terminate it. – paxdiablo Dec 01 '09 at 12:25
  • top level job is changing too , and getting new id every 15sec – soField Dec 01 '09 at 12:29
  • Then find its PPID and see what process is starting it. Eventually you'll find a long-lived process and that's the one you should concern yourself with. – paxdiablo Dec 01 '09 at 12:33
  • i killed ppid of waiting process which is sleep 15 command then , all died. – soField Dec 01 '09 at 12:55
9

To delete a job which has not yet run, you need the atrm command. You can use atq command to get its number in the at list.

To kill a job which has already started to run, you'll need to grep for it using:

ps -eaf | grep <command name>

and then use kill to stop it.

A quicker way to do this on most systems is:

pkill <command name>
Ry-
  • 199,309
  • 51
  • 404
  • 420
Benj
  • 29,382
  • 17
  • 72
  • 119
3

at -l to list jobs, which gives return like this:

age2%> at -l
11      2014-10-21 10:11 a hoppent
10      2014-10-19 13:28 a hoppent

atrm 10 kills job 10

Or so my sysadmin told me, and it

1

First

ps -ef

to list all processes. Note the the process number of the one you want to kill. Then

kill 1234

were you replace 1234 with the process number that you want.

Alternatively, if you are absolutely certain that there is only one process with a particular name, or you want to kill multiple processes which share the same name

killall processname
bguiz
  • 22,661
  • 40
  • 140
  • 226
  • 2
    `killall` works on Linux, but do note that on some systems, like Solaris, it actually *kills all processes*, which probably isn't what you want. – Jason Orendorff Dec 01 '09 at 12:04
  • 1
    Wow, Solaris is DUMB. Why would you ever want to do that? Is like having an alias to 'rm -rf /' – polvoazul Oct 31 '13 at 17:15