Posts tagged disconnect
If you need to execute a process that will run in the background so that it does not lock one terminal window then you should try using the NOHUP command.
nohup <command here> &
After executing it, a nohup.out file will be created (append if it exists) which will contain all the output from the command (if any).
However, if you want to close the terminal window, like if you are working on a remote machine, do the following:
(nohup <command here> & ) &
This will disconnect the process from your session completely so you should be able to close the terminal window and do not interrupt the process.
To check if the process is still running, perform the following:
ps -ef|grep -i <command name or part of command name>
This is listing all the processes on the machine and then grepping for the command name with case insensitive (-i).
If you want to stop the process, you will need to kill it with the following command:
kill <process id>
The process-id can be seen from running the ps command above. In most instances it is the first number of the row.
If the process hangs after the kill command, do force kill:
kill -9 <process id>
This will kill any process, so please double check the process id before executing it.