2

After some researches, it occurs that even if I can find some talks about multiple actions when restarting a service, it also seems it it not really possible to achieve :

 if failed port 80 and protocol http
     then exec /home/sweet/script.pl
     and restart

When declaring the restart command for a service in the monitrc configuration file, is it ok to try something like this :

restart program = "perl /home/sweet/crazy-stuff.pl && /etc/init.d/server restart"

As monit -t don't mention any error I prefer to ask before to do bad things.

3

You should use exec and a bash subshell, for example:

exec "/bin/bash -c '/etc/init.d/server restart && perl /home/sweet/script.pl'"

However, best practice recommends using a single script for all your actions ( meaning include the init.d restart command into your shell script.)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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