Job control is probably my favorite thing about Linux. I find myself, often, starting a computationally demanding process that basically renders a computer unusable for up to days at a time, and being thankful that there is always CTRL-Z
and fg
, in case I need to use that particular computer during that particular time period.
Sometimes, however, I want to insert a job onto the job stack. I've never figured out how to do that.
I'm using bash
.
It would probably look something like:
$ ./reallybigjob
^Z
[1]+ Stopped reallybigjob
$ (stuff I don't know) && ./otherbigjob
$ fg
Best Answer
There is no job stack, each job is handled independently.
You can do
fg; otherbigjob
. That will putreallybigjob
back to the foreground, then when thefg
command stops runotherbigjob
. This isn't the same thing as queuingotherbigjob
for execution after the first job: if you press Ctrl+Z thenotherbigjob
starts immediately. If you press Ctrl+C thenreallybigjob
is killed. You can't leaveotherbigjob
in the background and queue another job after it.If the jobs are CPU-intensive, then the
batch
utility can let you schedule the next job when the CPU isn't busy.