How can I run a Linux command that still runs after I close my PuTTY SSH session?

為{幸葍}努か 提交于 2019-12-01 11:47:23

Start your task with 'nohup' and put it in the background with '&', e.g.:

$ nohup mv /here /there &
$ exit

and it should continue running.

mattias

I would suggest using screen for this.

Start a new screen,

screen -S <name of your screen>

and then you can perform your commands there, detach from the screen and re-attach to it at any time.

Detach by hitting the sequence

ctrl a d

and re-attach by typing

screen -r (or list the screens with screen -l).

Also have a look at Gnu screen survival guide.

You can run it as a background process as follows:

nohup mv source target &

However, you will not be able to interact with the process.

EDIT: nohup is also required to keep it running after the shell exits.

Using nohup would be best solution.

The following command in your terminal may help you out to run the script using nohup and redirect the output in your desired file.

General Syntax

nohup some_command &> nohup_log_file_name.out &

Example

nohup python script.py &> nohup_log_script.out & 

So, if you use the above command, you will be able to find the outputs of the command in a log file named nohup_log_script.out

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!