Search code examples
pythontwistednohuptwisted.internettwistd

twistd and nohup &: what is the difference?


What are the advantages of using twistd over nohup?

Why doing

twistd -y service.tac

when I can do:

nohup sudo python my_app.py &

?

I am asking this because I faced a difficulty to use twistd, see my question here


Solution

  • nohup vs. daemonization is explained beautifully in this answer, which basically can be tl;dr'd to nohup command & being the "poor man;s way to daemonize a process, as it doesn't go through all the steps that daemonization goes through. Some minor differences:

    • nohup will not become the process group leader, nor will detach itself from the session of the shell it was executed from, even if sub-shelled (i.e., (nohup command &) vs nohup command &, parentheses make a difference,
    • Has "has the same controlling terminal - it just ignores the terminals controls", although this may not apply to the sub-shelled command above (haven't tested).

    Simply put, it is not "true" daemonization - there are some differences that may not appear problematic now, but may do if you assume in the future that the process is truly daemonized, when really it hasn't truly been, and perform operations as if it had been.