Monit - How to add a delay between stop and start
Solution 1:
The command is
sleep
followed by a value in seconds.
So add sleep 10
between the lines and that should do it.
Note that it must be an integer value on solaris; on general linux decimals work too (you can put 10.15 or something else).
Solution 2:
Example:
start program = "/bin/sleep 90; /etc/init.d/apache2 start" with timeout 110 seconds
/bin/sleep
is what you want.
You could also specify a single shell script in place of what is in quotes to do that:
start program = "/home/user/scripts/my_custom_start.sh" with timeout 110 seconds
my_custom_start.sh:
#!/bin/sh
/bin/sleep 90
/etc/init.d/apache2 start
If you use a script in this manner, do not forget to specify your interpreter: #!/bin/sh
(or whatever) as per documentation and the correct permissions. Then simply add the sleep statement to the shell script where you need it along with your "start" process call(s). Do not forget the UID/GID you want to execute as (if needed).
Consult documentation here:
https://mmonit.com/monit/documentation/monit.html#SERVICE-METHODS