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 want to execute a script when monit is restarted. For my case, this mostly applies to the restart of the whole server.

How can I achieve this? Is there a way beside monit to do this?

Background: The server, where I need this, is a virtual server. It seems, that firewall rules in iptables are not persistant, so I need to set them on server start.

share|improve this question
    
Perhaps you should ask how to make the iptables firewall rules persistent, then, instead of this question? –  Michael Hampton Jul 30 '12 at 5:32
    
This would be an approach. But I'm using monit to start all services and check some things, so I would like to do this in there to keep things together. –  Martin Jul 30 '12 at 6:54
    
The Linux system will already have a "standard" way of persisting iptables, and it's usually best to use the normal ways. Otherwise you will end up with confusion later. –  Michael Hampton Jul 30 '12 at 7:12
add comment

1 Answer 1

By default, you should receive an alert that the Monit daemon restarted. Something like:

Monit instance changed Service localhost

    Date:        Sun, 29 Jul 2012 13:09:28
    Action:      start
    Host:        ppro.abc123.com
    Description: Monit started

Your faithful employee,
Monit

If you need something to run at boot, have you considered wrapping it in an init script? With Monit, there's a level of uptime testing, but it only applies to processes.

You could also choose to take an action on a change in Monit's PID... But I think it would help to get a better understanding of what you need to execute.

share|improve this answer
    
I added some background information. I hope, this helps understanding my problem. –  Martin Jul 30 '12 at 5:22
add comment

Your Answer

 
discard

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

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