How to open a process as daemon on Linux

Sometime we may need to open a process as daemon (the process should not die when the child process die). One of the easiest way to do that is to run the process from command line and add a & at the example. For example if you want Firefox to run from shell and don’t want to wait for Firefox to be closed, run “firefox &”.
But the problem with the approach is if you close the shell terminal, it will also close the process. You need to execute “exit” command to exit from shell properly. But if you use execute the process with “nohup” the problem is solved. For example, if you execute “nohup firefox &”, firefox will not close even if you close the shell.

It is very helpful if you want a process to run as a simple daemon. This is not the right way to make a process daemon, but this is a good workaround to get close to a daemon. So if you want a python script to run as daemon just run
nohup python /path/to/ &
and your process will run in background 🙂

Want to share your views? Please do reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s