You’re running a job at the terminal prompt, and it’s taking
a very long time. You want to put the job in the backgroud.
“CTL – z” Temporarily suspends the job
$ jobs This will list all the jobs
$ bg %jobnumber (bg %1) To run in the background
$ fg %jobnumber To bring back in the foreground
Need to kill all jobs — say you’re using several suspended
emacs sessions and you just want everything to exit.
$ kill -9 `jobs -p`
The “jobs -p” gives the process number of each job, and the
kill -9 kills everything. Yes, sometimes “kill -9” is excessive
and you should issue a “kill -15” that allows jobs to clean-up.
However, for exacs session, I prefer “kill -9” and haven’t had
a problem.
Sometimes you need to list the process id along with job
information. For instance, here’s process id with the listing.
$ jobs -pl
Note you can also renice a job, or give it lower priority.
$ nice -n +15 find . -ctime 2 -type f -exec ls {} \; > last48hours
^z
$ bg
So above that was a ctl-z to suppend. Then, bg to run it in
the background. Now, if you want to change the priority lower
you just renice it, once you know the process id.
$ jobs -pl
[1]+ 29388 Running nice -n +15 find . -ctime 2 -exec ls -l {} \; >mout &
$ renice +30 -p 29388
29388: old priority 15, new priority 19
19 was the lowest priority for this job. You cannot increase
the priority unless you are root.
Leave a comment