-1

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:

MAX=95
EMAIL=USER@domain.com
PART=sda1
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
fi

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
robue-a7119895
  • 167
  • 1
  • 8

1 Answers1

1

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?

keegan2149
  • 71
  • 3
  • 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 08:04