Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a program that I added to /etc/rc.local to have it run as soon as the server starts. The problem is that sometimes the program stops responding and I need to restart it but I can not restart the server. I can only restart the server at night but the program sometimes dies during the day.

share|improve this question

migrated from stackoverflow.com Mar 8 '11 at 15:28

This question came from our site for professional and enthusiast programmers.

1  
A) you should probably accept some previous answers to your other questions. B) This is better suited to another site like serverfault, superuser, ubuntu or linux. C) It depends on how you added it, bu /etc/ini.d/whatever start might do it. –  chmullig Mar 8 '11 at 15:14

3 Answers 3

Instead of putting it in rc.local directly, the "proper" way to do it is to put a script in /etc/init.d that will respond to 'start|stop|restart' to do the right things to the program's process, then have the system symlink it into the rc directories via update-rc.d scriptname defaults.

Then, use service scriptname restart to restart it.

share|improve this answer

As mentioned by Shane you'll want to create an init script to start/stop/restart the service. As far as the program not responding, you'll want to find the root cause of that first. You can also use GOD http://god.rubyforge.org/ to monitor and automatically restart the program (using your rc.local entry)

Hope that helps.

share|improve this answer

It is possible Ubuntu already has such a facility built-in via the standard rc system, but you might Google around "ubuntu daemon health monitor" and the like. I found a program called monit which you could probably install and configure to check in on your process and restart it when it fails.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.