Skip to content

Instantly share code, notes, and snippets.

@meinside
Last active February 16, 2017 09:21
Show Gist options
  • Save meinside/a404f44c1539cd0af017fe75a416eb2a to your computer and use it in GitHub Desktop.
Save meinside/a404f44c1539cd0af017fe75a416eb2a to your computer and use it in GitHub Desktop.
Sample bash script for checking unread mails in the spool.
#!/usr/bin/env bash
#
# script for checking local mail
#
#
# * for running every one hour:
#
# $ crontab -e
#
# # m h dom mon dow command
# * */1 * * * /path/to/check_mail.sh
num_mails=`grep "Subject:" "/var/spool/mail/$USER" 2> /dev/null | wc -l`
if [ $num_mails -gt 0 ]; then
echo "You've got mails"
else
echo "No mail"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment