I have a .py file that is ran by:

我有一个。py文件:

python a.py &

python。py &

I am using a ssh to run the command, after it I have to log off. I find after some time the process is exited. I suspect it's Linux send some signal to it? I think if I can make the daemon then I can avoid this?

我正在使用ssh运行这个命令,在它之后我必须注销。我怀疑是Linux给它发送信号?我想如果我能做这个守护进程我就能避免这个?

5 个解决方案

#1


7

Although nohup will work, it's a quick and dirty solution. To make a proper daemon process you need to use SysV init or (If you are running Ubuntu 6.10+ or Fedora 9+) upstart.

尽管nohup是有效的,但它是一个快速而肮脏的解决方案。要做一个适当的守护进程,您需要使用SysV init或(如果运行Ubuntu 6.10+或Fedora 9+) upstart。

Here's a simple script that starts a.py and restarts it whenever it gets killed (up to 5 times inside a 5 minute span):

下面是一个启动a的简单脚本。当它被杀死时(在5分钟内最多5次),就重新启动:

respawn

respawn limit 5 300

exec python /path/to/a.py

Then just put that script in /etc/init/.

然后把这个脚本放到/etc/init/中。

Upstart has a lot more options too. Checkout the Quick Start tutorial.

Upstart也有更多的选项。签出快速入门教程。

更多相关文章

  1. python解压zip脚本
  2. 使用python脚本配置zabbix发送报警邮件
  3. 见证历史!Python或将取代VBA,成为Excel官方脚本语言!
  4. Python标准库06 子进程 (subprocess包)
  5. 解决Linux下运行Python脚本显示“: 没有那个文件或目录”的问题
  6. 通过Excel / VBA运行Python脚本
  7. Python3 串口两进程同时读写
  8. 利用Dnspod api批量更新添加DNS解析【python脚本】
  9. 是否可以在没有安装铁python的PC上运行编译的铁python脚本?

随机推荐

  1. Android夸进程通信机制一:多进程简介
  2. android 2048游戏、kotlin应用、跑马灯、
  3. Android中layout_gravity和gravity的区别
  4. 七款android地图 [Map] 开源项目框架分类
  5. Android OpenGL教程-第一课
  6. android 创建AVD时 无系统镜像 No target
  7. Android(安卓)模仿360二维码扫描功能
  8. Android-安全退出
  9. android中shape的属性
  10. android兼容oppo手机刘海屏解决方案