Job Control

[problem]

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

[/problem]

[solution]

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

[/solution]

[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

[/example]

[reference]

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

[/reference]

If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

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