Friday, December 30, 2011

Linux: Run a process as daemon in background from SSH

When a process supports daemon mode, you can either run it in a screen instance or init.d script.

If you had to kill off a rogue daemon and need to start it again via SSH, you can restart the daemon with a very simple addition to the command:

For example you have /bin/daemon_process with the parameters "--daemon --log-path=~/logs/blah/"

You can execute it with:

/bin/daemon_process --daemon --log-path=~/logs/blah &

The extra & at the end makes it spit output to the current terminal, but it wont wait for the daemon to finish.

Source

1 comments:

  1. The nohup command can save your bacon if you want to run plain commands that can survive a dropped SSH connection. The following snippet will run the command in the background and log any output to the specified logfile:

    nohup command-name > nohup_log.txt &

    You'll have to kill the process when you no longer need it, of course.

    ReplyDelete

Leave your thoughts ...

---
If you are having trouble with copy/pasting in comments, you need to sign in or click 'Preview'.

For more information about this Firefox bug, see here.