Run Command in the Background

Command executed in the foreground will exit when the terminal is close. To prevent the program from closing, you need to run the command in the background.

To run the command in the background, just add ‘&’ at the end of the command

1
command &

However, when the terminal closes, the command will exit, to prevent the program from closing, append &>/dev/null & at the end.

1
nohup command >/dev/null &

nohup is short for “No Hangups”. It is a POSIX command to ignore the HUP (hangup) signal. By default nohup creates Nohup.out to output any messages or error. The redirect will prevent nohup from creating a nohup.out file.