我尝试通过远程会话启动一个 shell 脚本,它使用命令在后台启动一个进程。
nohup python3 run.py > nohup.out &
Run Code Online (Sandbox Code Playgroud)
当远程会话关闭时,进程会被以下消息杀死:
捕获信号SIGHUP
SIGHUP 被捕获但没有被守护。退出。
我不明白;为什么进程在使用nohup &在后台启动时被杀死?
我想在后台运行一个进程而不在 shell 退出时杀死它,根据 Nohup 概念,以下命令应该可以工作,直到我手动杀死它:
nohup uwsgi --http :8008 --module crawled_data_center.wsgi > /dev/null &
Run Code Online (Sandbox Code Playgroud)
我使用 root 用户登录到 shell,但是在退出 shell 后,进程终止了。这看起来很奇怪,因为我nohup
在几个项目中使用了几次并且工作正常,但在这种情况下我很糟糕,有什么问题,我怎样才能在后台运行它而不在 shell 退出时杀死它?
更新:
我处理它:
$ nohup uwsgi --http :8008 --module crawled_data_center.wsgi > /dev/null &
$ disown -l
$ disown -h JOBID
Run Code Online (Sandbox Code Playgroud)
但我的问题是关于它怎么SIGHUP
可能杀死nohup
和&
?
以下是内容/etc/systemd/logind.conf
:
[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
Controllers=blkio cpu cpuacct cpuset devices freezer hugetlb memory perf_event net_cls net_prio
ResetControllers=
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes …
Run Code Online (Sandbox Code Playgroud)