Last active
November 2, 2019 15:27
-
-
Save mintplugins/216b7a2ec9d858450ad7625c05e1eea7 to your computer and use it in GitHub Desktop.
Put this code in a shell file called "email-if-files-changed" somewhere on your server. Then link to it from a cronjob in your crontab file using this line: 01 1 * * * root /path-to-your-custom-script/email-if-files-changed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILES_CHANGED=$(find /var/www -type f -mmin -$((60*24)) -printf '%TY-%Tm-%Td %TT %p\n' | sort -r) | |
if [ !$FILES_CHANGED ] | |
then | |
curl -s --user 'api:MAILGUN_API_KEY' \ | |
https://api.mailgun.net/v3/YOURMAILGUNDOMAIN/messages \ | |
-F from='Name of your server<[email protected]>' \ | |
-F [email protected] \ | |
-F subject='No files were changed in the last 24 hours' \ | |
-F text="$FILES_CHANGED" | |
else | |
curl -s --user 'api:MAILGUN_API_KEY' \ | |
https://api.mailgun.net/v3/YOURMAILGUNDOMAIN/messages \ | |
-F from='Name of your server<[email protected]>' \ | |
-F [email protected] \ | |
-F subject='Files were changed in the last 24 hours' \ | |
-F text="$FILES_CHANGED" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment