Search code examples
linuxbackground-processnohupremote-control

Continuing an operation if terminal closes


I need to execute this command on my terminal, that will operate on a server. I need to modify it such that if I lost the connection and the terminal closes, the operation running is not stopped, continuing the operation until its conclusion.

for file in 4458*/payoffTable* ; do cp "$file" /storage/scratch2/id0056/DMM_BASTIAN/M_7/N_15_P_05/Evoluzioni;done &

I know there is a command, called "nohup", that allow that, but if I prepend it to the previous command I get an error. Also, in the case in which some of you is able to give a solution to this problem, I would like to know how to monitor the background processes running on a remote server. Thanks for the help.


Solution

  • After the execution of nohup the terminal returns the PID (Process ID) that is the process identifier. By opening a terminal and running the command ps -ef | grep PID the console returns your process created above, if still running. If the process is not returned, it means that the execution is completed.