Keep program running after logout with nohup
2019-09-03T12:14:08Z.
One can use nohup to make sure a program keep running even
after logout.
The output written to standard output and standard error will be written
to the nohup.out file in the current directory.
Run a command with nohup
To run a command with nohup:
nohup COMMAND &
For example:
nohup ls /tmp &
Run a script file with nohup
Assume you have a script file run.sh, you can run the script
with nohup:
nohup sh run.sh &
Run several commands with nohup
You can also run several commands with nohup. For example, if
you want to create archives of several large directories
data1, data2, and data3:
nohup sh -c " \
tar -cjf data1{.tar.bz2,} ; \
tar -cjf data2{.tar.bz2,} ; \
tar -cjf data3{.tar.bz2,} ; \
" &