I have CentOs 6.5 running on a VPS Host. I installed crontab and email using the below commands

yum install vixie-cron
service start crond
chkconfig crond --levels 235 on

yum install sendmail
service start sendmail
chkconfig sendmail --levels 235 on

Now, since I wanted my VPS to send me email, every 5 minutes (for test) about my server status, I found a script (5th example) that does that, or you can see it below:

USE=`df -h |grep $PART | awk '{ print $5 }' | cut -d'%' -f1`
if [ $USE -gt $MAX ]; then
  echo "Percent used: $USE" | mail -s "Running out of disk space" $EMAIL

I downloaded the script using curl from the given URL and modified the EMAIL to reflect my email account.

Now, the last thing I did was, put the above shell script in /home/user/status.sh and went in to tell cron tab to run it every five minutes.

$ crontab -e
*/5 * * * * /home/user/status.sh

I assumed this is enough to get the email, but I am not getting any. I have no problems with my email account. What could be the problem?

Additional Info:

  1. I have root access. Just in case you thought I didn't.

  2. And here is my cron log

[root@user log]# tail /var/log/cron Aug 17 15:15:31 site-name run-parts(/etc/cron.daily)[526]: finished makewhatis.cron Aug 17 15:15:31 site-name anacron[29624]: Job `cron.daily' terminated Aug 17 15:20:01 site-name CROND[622]: (root) CMD (/home/user/status.sh) Aug 17 15:25:01 site-name CROND[744]: (root) CMD (/home/user/status.sh)

  1. And My maillog enter image description here

closed as off-topic by Iain, kasperd, Ward, mdpc, MadHatter Aug 20 '14 at 15:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – mdpc, MadHatter
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Did you try running the script yourself? What's in the logs? – Michael Hampton Aug 17 '14 at 13:25
  • @MichaelHampton No. I guess I should run it. I have included the logs. – robue-a7119895 Aug 17 '14 at 13:28
  • That's not the mail log! – Michael Hampton Aug 17 '14 at 13:28
  • Have you tried sending a mail from the command line to verify that your mail is working ? – Iain Aug 17 '14 at 13:30
  • 1
    Have you also considered the possibility that you aren't running out of disk space? The script won't mail you anything in that case. – Michael Hampton Aug 17 '14 at 13:30

Is that the entire script? There's no 'shebang' line add #!/bin/bash to the first line if it isn't there already. Also did you mark the file executable?

  • it actually worked without the sheband. I just had to edit the crontab to */5 * * * * /usr/sbin/bash /home/user/status.sh – robue-a7119895 Aug 17 '14 at 20:05
  • That's basically the same thing. The shebang line and the executable flag allows you to run the script on it's own. Without it you have to run bash and give the file as input whenever you want to run it. – keegan2149 Aug 19 '14 at 8:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.