Skip to content

Instantly share code, notes, and snippets.

@alexalouit
Last active February 19, 2018 10:21
Show Gist options
  • Save alexalouit/4cd695c7279bcc9b9d3e to your computer and use it in GitHub Desktop.
Save alexalouit/4cd695c7279bcc9b9d3e to your computer and use it in GitHub Desktop.
Getmail survey lock file (semaphore)
#!/bin/bash
#
# cron ex: */30 * * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/survey-semaphore-getmail.sh >> /root/scripts/cron.log
email=""
# file exist and have invalid ttl?
if [ -f /tmp/.getmail_lock ]
then
# have a correct ttl?
if [ $(find /tmp/.getmail_lock -type f -cmin +900) ]
then
# send alert
echo -e "Erreur du semaphore getmail sur le serveur:\n $(hostname)" | mail -s "Rapport d'erreur getmail" $email
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment