How do I daemonize an arbitrary script in unix?

后端 未结 12 970
陌清茗
陌清茗 2020-11-30 16:33

I\'d like a daemonizer that can turn an arbitrary, generic script or command into a daemon.

There are two common cases I\'d like to deal with:

  1. I hav

12条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 17:19

    First get createDaemon() from http://code.activestate.com/recipes/278731/

    Then the main code:

    import subprocess
    import sys
    import time
    
    createDaemon()
    
    while True:
        subprocess.call(" ".join(sys.argv[1:]),shell=True)
        time.sleep(10)
    

提交回复
热议问题