How to start a Linux command in background

Submitted by admin on Sun, 05/19/2019 - 09:43

Start a Linux Process or a Command in Background

simply press Ctrl+Z to stop it then enter the command bg to continue with its execution in the background as a job. Or you can use the ampersand sign & at the end of a command to directly run a process in the background 

# some_long_command &

You can view all your background jobs by typing jobs


Keep Linux Processes Running After Exiting Terminal

We will use disown command, it is used after a process has been launched and put in the background, it’s work is to remove a shell job from the shell’s active list jobs, therefore you will not use the fgbg commands on that particular job anymore. Or You can also use the nohup command at the beginning of a Linux command

# disown -h %1

%1 is the number of the process from jobs output

# nohup some_long_command &


Get back a Linux process from background

you can use the jobs command to see all background Linux processes and use  the fg and bg commands to switch them in foreground and background.