jobs and (in ) Updated: 11/13/2000 1:30PM ("process status") and jobs ps -ef (-e and -f) (see also ) (briefly) (see also "grep")

For a discussion about job control in Autosys, see the Autosys article.

Showing what processes we have running

Some examples: jobs Shows what jobs you have running. Only jobs that are attached to your terminal are shown. For example:

$ 100 & ... $ jobs [1] + Running sleep 100 & $

A job is displayed with a job number. In this case it's "1". This number is only meaningful to the same shell (session) you started it in. on this job id in a bit. ps To view processes that you've started. Without any additional arguments, ps will show only the processes attached your terminal, and only the tinest bit of about them. One piece of information that's shown is the PID (Process ID), it is the global reference to a process (as opposed to a job id that will work only in the shell (session) you're logged into). More about the process id in a bit. ps -e Shows all process on the system (in addition to the ones you've started). ps -f Shows processes in a long format, with a lot more information. See ps(1) for the explanation of the columns. ps -ef Shows all process on the system with a long format. The above example is great, but it would be if we could only see the jobs related to us (assuming I'm logged in as psfts760)? See below.

Killing jobs Suppose I wanted to kill a job like my "sleep 100". If I am using the same shell (session) and know the job id, I can use the kill command. To use the job id, I have to put a percent sign in front ' %'.

$ sleep 100 & ... $ jobs [1] + Running sleep 100 & $ kill %1 $ [1] + Terminated sleep 100 & $

What if I logged out for the evening or nohup' a job. I no longer have job id associated with that process. I have to use the "global" process id. I could do a "ps -ef", but that would show me every process on the system. I donly want to kill the process that belongs to me.

$ ps -ef|grep psfts760 psfts760 25052 1 0 Nov 12 ? 3:02 PSRUN.sesprod PTPUPRCS psfts760 25063 1 0 Nov 12 ? 5:27 oraclesesprod (DESCRIPTION=(LOCA L=)(ADDRESS=(PROTOCOL=beq psfts760 27583 27350 4 12:31:49 pts/th 0:00 sleep 100 psfts760 27399 27350 1 12:30:24 pts/th 0:00 grep psfts760 psfts760 14855 14854 0 09:13:37 pts/tf 0:00 -sh psfts760 27398 27350 1 12:30:24 pts/th 0:00 ps -ef $

(In fact, I could search on anything. I could have done a " ps -ef|grep sleep" would have been better. Also, notice that " grep psfts760" is there in the listing, you could say that I see myself looking for me.)

The owner of the process, me as psfts760, is shown in the first column. And the next column is the process id. To kill it, do a

$ kill 27583

This allows the program to die gracefully. And then repeat a " ps -ef|grep psfts760" to see if it's still there or not. If you've waited long enough (about 10 seconds or so) for it to die on its own and clean up in its own and it hasn't died yet, you can use the -9 option.

$ kill -9 27583

We generally, don't recommend supplying the -9 option until as a last resort. (With the -9 option, the rips the program out of memory.) We want to give the program to die on its own accord and clean up whatever it was doing. (You can use the -9 option with the job id too. Eg: kill -9 %1 )