Problem running python/matplotlib in background after ending ssh session

后端 未结 4 586
长发绾君心
长发绾君心 2020-12-24 07:50

I have to VPN and then ssh from home to my work server and want to run a python script in the background, then log out of the ssh session. My script makes several histogram

4条回答
  •  渐次进展
    2020-12-24 08:42

    If you are running on a *nix OS the problem is your session is terminated and all processes requiring a session are also terminated when you disconnect. More specifically all your processes are sent a SIGHUP (signal hang-up). The default handling of SITHUP is to terminate the process. If you want you script to continue it needs to ignore the signal. The easiest way to do that assuming you start your script via the command line it to run it using the nohup command:

    nohup python scriptToRun.py << start>& logfile.log&
    

    nohup normally sends standard out and standard error to the file nohup.out in the current directory. Since you're redirecting already output nohup.out will not be created.

提交回复
热议问题