Sunday, March 4, 2018

Keep the process of a program running after closing the shell terminal

to keep the process running after the shell terminal close on ubuntu 16.04 use the following
command:

nohup my_command > my.log 2>&1 &

if you don't want to log the output of this command to a log file the replace my.log by
/dev/null, So it will be like the following:

nohup my_command > /dev/null 2>&1 &

if you want to find the process after a while and want to kill the process then, list all
the running processes:

ps -ef

you will find the command in the CMD column of the diplayed list. Now find the process Id from
the PID column and insert the kill command

sudo kill pid

No comments:

Post a Comment