This is a bash implementation of a killswitch, which will monitor some action and raise an alert when the action fails or stops being performed.
This particular implementation runs an hourly backup script, and runs the killswitch daily at 4 AM to raise an alert if backups from the previous 24 hours failed.
The cron job runs an hourly backup command:
run-backup.sh && touch killswitch
This will touch the status file alive
only if the run-backup.sh
script succeeds
(that's the &&
notation).
If the backup script fails, the killswitch status file will not be touched, and the killswitch will be activated.
The cron job runs a daily killswitch script:
killswitch.sh
this runs each day at 4 AM.