I'm monitoring mysqld with monit but I would like that if I stop monit then the mysqld service also stops.


The easy way to do this is to modify the Monit init.d script to also stop mysqld. The main problem with this is that future updates to the Monit package may overwrite your changes.

Alternatively, you could write your own init.d script that controls mysqld and monit, and use that instead of the provided init.d scripts.


You fundamentally can't, and shouldn't want to, because that's not the way monit is designed to work. Monit is, as the name suggests, a monitoring system, that has some automatic problem-handling logic built-in. I also can't imagine why you'd want to do something like this, so I'm at a loss to give you alternative solutions to your actual problem.


This might be a a bit simplistic, but have you thought about this:

create a script that just stops/starts both services at the same time, and use that to call them instead of the regular init.d scripts?

You could put them into your bin folder if you want to be able to run them as a command.


Is it because you want to stop MySQL and do maintenance or whatever?

If so, just:

'monit unmonitor name_of_service_check_here'

... and monit will leave it be. If you have configured a monit state file (defaults to /var/.monit_state or something), then monit remembers unmonitors and such even after a reboot. You might also want to try the monit status to see current status for all or one given check:

monit status

Like Womble said, start by explaining what problem you have instead of focusing on one (probably bad) work-around.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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