Last active
February 16, 2017 09:21
-
-
Save meinside/a404f44c1539cd0af017fe75a416eb2a to your computer and use it in GitHub Desktop.
Sample bash script for checking unread mails in the spool.
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
#!/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