When troubleshooting cron mail delivery issues on CentOS 6, the first step is identifying which Mail Transfer Agent (MTA) cron is configured to use. The crontab man page mentions two possibilities:
# Check cron's mailer configuration in crontab $ grep MAILTO /etc/crontab $ cat /etc/crontab | grep -i mail
CentOS 6 typically comes with sendmail or postfix pre-installed, but cron might be configured differently. Here's how to check:
# Check which MTA is installed $ rpm -qa | grep -E 'sendmail|postfix|mailx' # Verify active MTA service $ service --status-all | grep -E 'sendmail|postfix' # Alternative method to check default mailer $ ls -l /usr/sbin/sendmail
These files control cron's mailing behavior:
/etc/crontab /etc/cron.d/* /etc/sysconfig/crond /etc/mail.rc (for mailx configuration)
Create a test cron job to verify mail delivery:
# Add this to crontab (crontab -e) * * * * * /bin/echo "Test mail from cron" | mail -s "Cron Test" your@email.com # Alternative using sendmail directly * * * * * /bin/echo "Subject: Cron Test\n\nTest mail from cron" | /usr/sbin/sendmail your@email.com
If mail isn't being delivered, check these common problems:
- MAILTO variable not set in crontab
- Firewall blocking SMTP port (25)
- Local MTA service not running
- Incorrect mail server configuration
- Mail queue issues (check with mailq command)
To explicitly configure cron to use a specific mailer:
# In /etc/sysconfig/crond CRONDARGS="-m /usr/sbin/sendmail" # Or for mailx CRONDARGS="-m /bin/mail"
After making changes, restart the crond service:
$ service crond restart
For more detailed troubleshooting, examine mail logs:
$ tail -f /var/log/maillog $ grep cron /var/log/maillog $ mailq (for sendmail/postfix queue inspection)
When troubleshooting cron mail delivery issues on CentOS 6 systems, the first critical step is identifying which mail transfer agent (MTA) cron is configured to use. The crontab man page hints at two possibilities:
# From crontab(5) man page: # "This option is useful if you decide on /bin/mail instead of /usr/lib/sendmail # as your mailer when you install cron"
There are several ways to determine which mailer cron is actually using:
# Method 1: Check cron's compile-time configuration cat /etc/sysconfig/crond | grep -i mail # Method 2: Examine running cron process ps aux | grep cron | grep -v grep
To verify your system's default mail setup:
# Check mail alternatives (if available) ls -l /etc/alternatives/mta # Verify sendmail location which sendmail ls -l /usr/sbin/sendmail # Check for postfix or other MTAs rpm -qa | grep -E 'postfix|sendmail|exim'
To isolate whether the issue is with cron or the mail system itself:
# Test using system mail command echo "Test message" | mail -s "Test subject" user@example.com # Test using sendmail directly echo "Subject: Test" | sendmail -v user@example.com
You can control cron's mail delivery through these approaches:
# Example crontab with MAILTO specification MAILTO="admin@example.com" * * * * * /path/to/script.sh # Disable mail entirely MAILTO="" * * * * * /path/to/script.sh >/dev/null 2>&1
Common problems in CentOS 6 cron mail delivery include:
- Missing or misconfigured local mail server
- Firewall blocking outbound SMTP
- Incorrect permissions on mail spool files
- Mail server not running or misconfigured