LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-26-2009, 11:39 AM   #1
DarkAge
LQ Newbie
 
Registered: Sep 2006
Posts: 15

Rep: Reputation: 0
crontab does not send out mails


I've got a centos v. 5.2 that doesn't send out mails when running cron tasks.

I've checked the following:
1. crontab MAILTO is set to my email
2. cron tasks do not direct STDOUT/STDERR to bitbucket
3. sendmail is configured and working. I can send mails from my linux server to my email

I don't know of any other setting that could affect crontab not sending out email. There are no entries added to the maillog so it is not even trying.

I've got a pretty identical configured centos v. 4.1 server that does send out crontab emails.

Any suggestions on what to check ?

Thanks in advance.
 
Old 05-27-2009, 04:06 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Do you get any messages in /var/log/cron?
 
Old 05-27-2009, 12:10 PM   #3
DarkAge
LQ Newbie
 
Registered: Sep 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by billymayday View Post
Do you get any messages in /var/log/cron?
No errors, and loads of lines that show successfull execution.

eg:
May 27 18:00:01 servername crond[9757]: (root) CMD (run-parts /etc/cron.monthly)
 
Old 05-27-2009, 08:27 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,609

Rep: Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445
Setup a cronjob to send an email, then let it run, login as root (and/or the cron job owner) and check local mail via mailx cmd line tool.
If cron has an issue, it usually sends an internal email to root/user.
Also check /var/log/messages, /var/log/maillog.
Given that cron has a minimal default $PATH, its always advisable to specify complete/absolute paths to any cmds/files referenced.
 
Old 05-28-2009, 02:34 AM   #5
DarkAge
LQ Newbie
 
Registered: Sep 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by chrism01 View Post
Setup a cronjob to send an email, then let it run, login as root (and/or the cron job owner) and check local mail via mailx cmd line tool.
If cron has an issue, it usually sends an internal email to root/user.
Also check /var/log/messages, /var/log/maillog.
Given that cron has a minimal default $PATH, its always advisable to specify complete/absolute paths to any cmds/files referenced.
Just to clarify. The cron jobs are executed successfully.

All local mails are forwarded to external mail accounts via a MAIL_HUB in the sendmail configuration.

There are no entries in the /var/log/messages, /var/log/maillog, /var/log/cron that even indicates that cron is trying to send mail but failing.

I can send a mail to root or an external email account and in both cases the email is put in the right inbox.

To me it seems like there must be a global setting somewhere that turns emails on/off in Centos v. 5.2

This is a VPS server, if that has any relevance
 
Old 05-28-2009, 02:48 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
If you set up MAILTO in the crontab, this will override every other default setting. Can you post the line of the script which sends the mail (masking out the mail address, of course)?
 
Old 05-28-2009, 02:55 AM   #7
DarkAge
LQ Newbie
 
Registered: Sep 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
If you set up MAILTO in the crontab, this will override every other default setting. Can you post the line of the script which sends the mail (masking out the mail address, of course)?
Quote:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
[email protected]
HOME=/

# run-parts
27 * * * * root run-parts /etc/cron.hourly
0 */3 * * * root run-parts /etc/cron.3hourly
21 2 * * * root run-parts /etc/cron.daily
11 3 * * 0 root run-parts /etc/cron.weekly
4 3 25 * * root run-parts /etc/cron.monthly
The [email protected] email exists and I can send mail to it manually via sendmail.
 
Old 05-28-2009, 03:22 AM   #8
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Wha tmessages are you expecting from this crontab? Thsi is the "master" crontab correct? I'm not sure that I see a whole lot of traffic from here.

Why don't you create script in /etc/cron.hourly or similar to echo a message and confirm it's behaviour.
 
Old 05-28-2009, 03:42 AM   #9
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
I can confirm what billimayday said: from my CentOS 5.3 box I do not receive any mail from the system crontab. Putting a script in /etc/cron.hourly that spits some standard output and setting MAILTO to an external e-mail works for me.
 
Old 05-28-2009, 04:45 AM   #10
DarkAge
LQ Newbie
 
Registered: Sep 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by billymayday View Post
Wha tmessages are you expecting from this crontab? Thsi is the "master" crontab correct? I'm not sure that I see a whole lot of traffic from here.

Why don't you create script in /etc/cron.hourly or similar to echo a message and confirm it's behaviour.
An example is a shell script run in the daily crontab that takes backup of my mysql databases.

In centos v4 I get a daily mail that the backup has been taken. However in v5 no mails are sent.

Every cron job in v4 gives me a mail and I send the output of those into the bitbucket when im not interested in them, however none of the cron jobs send mail in v5.

I'm not sure what you mean with the "master" crontab. I didnt know there could be several. I only have this crontab.
 
Old 05-28-2009, 04:46 AM   #11
DarkAge
LQ Newbie
 
Registered: Sep 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
I can confirm what billimayday said: from my CentOS 5.3 box I do not receive any mail from the system crontab. Putting a script in /etc/cron.hourly that spits some standard output and setting MAILTO to an external e-mail works for me.
what do you mean with "spits" ?

I can try creating a hourly job that does echo "test" and see if i get a email with test
 
Old 05-28-2009, 07:12 AM   #12
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by DarkAge View Post
what do you mean with "spits" ?

I can try creating a hourly job that does echo "test" and see if i get a email with test
spits = gives, prints out. Let us know if your test is successful.
 
Old 05-28-2009, 11:39 PM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,609

Rep: Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445
As mentioned, this is the master root crontab. Each entry's file

27 * * * * root run-parts /etc/cron.hourly
0 */3 * * * root run-parts /etc/cron.3hourly
21 2 * * * root run-parts /etc/cron.daily
11 3 * * 0 root run-parts /etc/cron.weekly
4 3 25 * * root run-parts /etc/cron.monthly

is also a crontab if you look at them.
In addition, each user gets their own crontab, unless cron.deny is set.
Usually under /var/cron or /var/spool/cron or similar.
http://www.adminschoice.com/docs/crontab.htm
 
Old 05-28-2009, 11:42 PM   #14
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
I would assume that the backup is called from root's crontab. Edit this with "crontab -e" as root, and you will see a slightly different format from the one you have shown (no username in particular).
 
Old 09-12-2011, 05:00 AM   #15
sburnay
LQ Newbie
 
Registered: Sep 2011
Location: Lisbon, Portugal
Distribution: Ubuntu, CentOS & SUSE
Posts: 29

Rep: Reputation: Disabled
Hi!

I'm having the same problem with e-Mail sending from the cron tasks.

In fact, there is something curious I'll expose:

>>>>>>>>>>>> Running cat on /etc/crontab
Code:
[[email protected] cron]# cat /etc/crontab
#
# Minuto(0-59) Hora(0-23) Dia(1-31) Mes(1-12) DiaSemana(0-7[Dom=0ou7])
#
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
10 0 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
16 5 * * * root run-parts /etc/cron.spa
[[email protected] cron]#
>>>>>>>>>>>> Running 'crontab -e'
Code:
MAILTO=root
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/tmp/crontab.XXXX1YwgAi" 1L, 12C
I've seen in other posts this suggestion of using 'crontab -e' instead of a standard editor (nano in my case).

Could this be the source of my issue?

Anyway, by running 'crontab -e', you can see that the 'MAILTO=root' is already there.

That root is translated to a person's mail account in the '/etc/aliases' file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
To restrict a user to send mails only to 3 e-mails IDs using postfix mail server sharath41 Linux - Newbie 2 07-21-2008 07:38 PM
STRANGE:mailserver receives mails but is not able to send mails outside nics Linux - Server 1 05-04-2007 12:44 AM
Sendmai can send mails but unable to receive mails satimis Linux - Server 2 02-15-2007 09:22 AM
Silencing Crontab Mails jon_k Linux - Software 3 10-03-2004 07:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration