I wrote a shell script for monitoring a Rest API, when it is down the shell script send two mails one for the developer and the other for the manager. The problem is that I need to this with this frequency:
Runs every 15 min during office hours (9-18 hours) during working days and send mail to manager and developer
Every hour 6-9 pm and from 18 to 24h on working days runs and sends mail to manager.
Runs every 3 hours from 00:00 to 6:00 every night and the holidays and send mail to manager
¿How can I discard between holidays and work days?
You'll need several entries:
Every 15 min during office hours
*/15 09-18 * * * yourscript.sh
Send email only to manager, add an if inside the script that will check for the hour and send only to the manager
00 06-09,18-23 * * * yourscript.sh
Send every three hours
00 00,03,06 * * * yourscript.sh
For not running on holidays, cron will not be able to help, you will need to get from a different source a file which lists all the holidays and then add an if inside your script.
#!/bin/sh
if [ grep -q `date +%F` /random_location/holidays.txt]; then
exit 0
fi
# Continue your script from here