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.

This question is an exact duplicate of:

I have a long running daemon I need to take down for maintenance every now and then, is there an easy way to run monit stop <name>, but if the process doesn't stop after a period of time then to just force kill it? Or does this have to be part of whatever script I tell monit to run to kill the process?

share|improve this question

marked as duplicate by Chris S Feb 27 '13 at 22:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
What is wrong with using the system's commands to manage daemons? –  vonbrand Feb 27 '13 at 13:23
    
I've written a daemon from scratch that does not on its own take care of that, my question is do I need to, or is there some kind of system command to take care of that for me? Sorry, total newbie! –  Mohamed Hafez Feb 27 '13 at 16:46
    
Search on how your system handles booting (that is quite variable, simplest alternative are latest Linux with systemd), and look for examples of how to write dæmons. If your system uses systemd, note that it takes over many chores in dæmon writing. –  vonbrand Feb 27 '13 at 16:51

1 Answer 1

Found the answer I was looking for: use start-stop-daemon to start and stop the daemon, and all the pidfile management, not restarting if its already running, and killing the daemon if it doesn't die on its own after sending it TERM, etc, will be taken care of according to the parameters you pass.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.