I'm using centos 7.0/6.5. The content of /etc/cron.hourly/mail.cron
#!/bin/sh
log=/var/log/mail.cron.log
echo "`hostname` `date`" >> $log 2>&1
mailx -s "test mail" me@example.com < $log
The result of /var/log/mail.cron.log
myhost Mon Jul 28 11:01:01 CST 2014
But, I got a empty e-mail, with correct subject. So, I test this cron manually. I got the correct e-mail content.
myhost Mon Jul 28 11:01:01 CST 2014
myhost Mon Jul 28 11:30:29 CST 2014
Here is the related log /var/log/cron
Jul 28 11:01:01 myhost run-parts(/etc/cron.hourly)[24577]: starting mail.cron
Jul 28 11:01:02 myhost run-parts(/etc/cron.hourly)[24605]: finished mail.cron
I'm wonder how to debug this problem.