Background process

There are multiple ways to place a program in background mode. Background mode is when the program runs and returns you the prompt back and the program is till running but it can be tied to the session or untied to the shell.

The following scenario is when a process is tied to a shell:
Example: $ sleep 60 &
In the above example you are starting “sleep” in background, it will return the prompt back to you while the program runs.

In the case if the program is started but not in background mode, by pressing Ctrl-Z will suspended the program and return the prompt back to you, at that point the program is no longer running i.e. is suspended, so typing “bg” will place the program in background mode and return the prompt back to you.

Example: $ sleep 60
<Press Ctrl-Z>
Stopped
$ bg

By using nohup infront of the command the command is not tied to shell, example:
$ nohup sleep 60 &

Leave a Reply