Job Control

Problem

You want to background a process, or leave it running whilst shutting the terminal.



Solution

To start a UNIX process is the background, simply append the command with an ampersand, like this below.



Example



sleep 30&;

If you have already started a process and want to start in the background, just hit control Z. Then type bg to background (and continue running) the command.

To display jobs in the background, runs command jobs

To bring back into the foreground, run fg

It is always a good idea to redirect output, for backgrounded jobs. Also if you are going to exit the shell, need to prefix the command with nohup. Or if it is already running, background the job and run disown



Reference

[tags]UNIX Batch Mode, UNIX Background Process, Unix Coding School[/tags]



Leave a Reply

Your email address will not be published. Required fields are marked *