Execute Commands After You Exit From a Shell Prompt (by LinuxTitli)
nohup
Most of the time you login into remote server via ssh. If you start a shell script or command and you exit (abort remote connection), the process / command will get killed. Sometime job or command takes a long time. If you are not sure when the job will finish, then it is better to leave job running in background. However, if you logout the system, the job will be stopped. What do you do? nohup commandAnswer is simple, use nohup utility which allows to run command/process or shell script that can continue running in the background after you log out from a shell:
If you have created a background process and you log off, your process will be killed since it is associated with your shell. The nohup (no hangup) command allows you to keep processes running after you have logged off. The nohup command, is usefull if you have a process that needs to run all night or a few weeks.
nohup Syntax
# nohup command-name &Where
- command-name : is name of shell script or command name. You can pass argument to command or a shell script.
- & : nohup does not automatically put the command it runs in the background; you must do that explicitly, by ending the command line with an & symbol.
nohup command examples
- Login to remote server
- Execute script called pullftp.sh
- Type exit or press CTRL + D exit from remote server.
- find&kill a process when you login again see reference
# ssh user@remote.server.com
# nohup pullftp.sh &
# exit
# ps -ef | grep sleep scot 8419 4944 3 20:17:42 ttyp2 0:00 grep sleep scot 8416 4944 0 20:17:32 ttyp2 0:00 sleep 400 # kill 8416 [2] Terminated sleep 400 #
run MATLAB in the Background on a Linux Server
see reference# nohup matlab -nodisplay < YOUR_MATLAB_FILE.m > output.txt &
Labels: BASH
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home