python程序linux后台运行

linux程序后台运行

linux信号量

  • SIGINT
    • Ctrl + C发送sigint信号量
  • SIGHUP
    • 关闭session发送sighup信号量

启动命令

程序

test.py

# encoding=utf8
import time
if __name__ == "__main__":
    i = 0
    while True:
        print i
        time.sleep(1)
  • python test.py &

    • 输出到终端
    • 接收SIGHUP信号量杀死进程
    • 不响应SIGINT信号量
  • nohup python test.py

    • 输出到nohup.out
    • 接收SIGINT信号量杀死进程
    • 不响应SIGHUP信号量
  • nohup python test.py &

    • 不输出
    • 不响应SIGHUP信号量
    • 不响应SIGINT信号量
    • 用kill命令结束进程

猜你喜欢

转载自blog.csdn.net/chinesesexyman/article/details/105513626
今日推荐