# Cron tasks not running (or email not being sent) [SOLVED]

## dageyra

For some reason, my cron tasks are not running, or I'm not getting notification that it is.  I have it setup as such where I get an email with the output of the cron jobs:

```

$ cat /etc/crontab

# for vixie cron

#

# $Header: /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v 1.1 2005/03/04 23:59:48 ciaranm Exp $

#

#

# Global variables

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=ryan@dagey.com

HOME=/

# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly

0  *  * * *     root    rm -f /var/spool/cron/lastrun/cron.hourly

#56  15  * * *  root    rm -f /var/spool/cron/lastrun/cron.daily

1  3  * * *     root    rm -f /var/spool/cron/lastrun/cron.daily

15 4  * * 6     root    rm -f /var/spool/cron/lastrun/cron.weekly

30 5  1 * *     root    rm -f /var/spool/cron/lastrun/cron.monthly

*/10  *  * * *  root    test -x /usr/sbin/run-crons && /usr/sbin/run-crons

```

But I never get the email.  Further, using cron.daily as a base (because it does my spam updatting), none of the scripts in /etc/cron.daily seem to run.  I have a script spam_check.sh that removes all spam from user's mailboxes in a special folder called Spam that is older than 3 days.  If I run this script manually, it works fine.  Running the run-parts on /etc/cron.daily works fine, but the spam files are not deleted and I never get an email.

I do see the following as far as /var/spool/cron is concerned:

```

# ls -l /var/spool/cron/

total 8

drwx-wx--T 2 root crontab 4096 Sep 11  2007 crontabs

drwxr-x--- 2 root root    4096 Jun 25 13:00 lastrun

```

Which shows the lastrun file is being updated properly.

Suggestions on how to determine what is not working properly?Last edited by dageyra on Tue Jul 15, 2008 1:13 am; edited 1 time in total

----------

## smerf

Can you send mail using 'mail' commandline utility?

Have you tried to put some talkative job directly inside crontab?

Is there anything cron-related in logs (try grep cron /var/log/ -r | less)?

----------

## dageyra

 *smerf wrote:*   

> Can you send mail using 'mail' commandline utility?
> 
> Have you tried to put some talkative job directly inside crontab?
> 
> Is there anything cron-related in logs (try grep cron /var/log/ -r | less)?

 

Thanks for all your help.

There are several crontab jobs that spit out stuff.  When I run the commands directly via the "test -x ...", I see the output.

The command 'mail' is unknown, I use postfix for my MTA, could that be a culprit?

It does appear like cron is working, but as I said, the spam folder is not being removed via tmpwatch and portage doesn't get updated, two scripts that work when executed directly:

```

/var/log/syslog:Jun 28 21:00:01 dev cron[28054]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )

/var/log/syslog:Jun 28 21:00:01 dev cron[28056]: (root) CMD (rm -f /var/spool/cron/lastrun/cron.hourly)

/var/log/syslog:Jun 28 21:01:01 dev cron[28077]: (dageyra) CMD (/data/bittorrent/watch/aim2torrent )

/var/log/syslog:Jun 28 21:06:01 dev cron[28119]: (dageyra) CMD (/data/bittorrent/watch/aim2torrent )

/var/log/syslog:Jun 28 21:10:01 dev cron[28131]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )

/var/log/syslog:Jun 28 21:11:01 dev cron[28143]: (dageyra) CMD (/data/bittorrent/watch/aim2torrent )

/var/log/syslog:Jun 28 21:16:01 dev cron[28155]: (dageyra) CMD (/data/bittorrent/watch/aim2torrent )

/var/log/syslog:Jun 28 21:20:01 dev cron[28174]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )

/var/log/syslog:Jun 28 21:21:01 dev cron[28186]: (dageyra) CMD (/data/bittorrent/watch/aim2torrent )

/var/log/syslog:Jun 28 21:26:01 dev cron[28236]: (dageyra) CMD (/data/bittorrent/watch/aim2torrent )

/var/log/syslog:Jun 28 21:30:01 dev cron[28258]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )

/var/log/syslog:Jun 28 21:31:01 dev cron[28270]: (dageyra) CMD (/data/bittorrent/watch/aim2torrent )

/var/log/syslog:Jun 28 21:36:01 dev cron[28298]: (dageyra) CMD (/data/bittorrent/watch/aim2torrent )

/var/log/syslog:Jun 28 21:40:01 dev cron[28317]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )

/var/log/syslog:Jun 28 21:41:01 dev cron[28342]: (dageyra) CMD (/data/bittorrent/watch/aim2torrent )

```

Any further tips/suggestions?

----------

## bunder

do you have ssmtp installed and configured?  i'd also run "find / | grep dead.letter" to see if the mails are still stored somewhere on the fs (might be /home/user, might be /var/spool, it's been a while).

i'd also try dropping the variables from your crontab, but i use dcron, so i'm not sure if you really need them.  (ssmtp does the MAILTO, and the rest should be automatic)

what are the permissions on the /etc/cron.daily/scripts you added?  note: your cron.daily is commented out in your sample.

cheers

----------

## dageyra

 *bunder wrote:*   

> do you have ssmtp installed and configured?  i'd also run "find / | grep dead.letter" to see if the mails are still stored somewhere on the fs (might be /home/user, might be /var/spool, it's been a while).
> 
> i'd also try dropping the variables from your crontab, but i use dcron, so i'm not sure if you really need them.  (ssmtp does the MAILTO, and the rest should be automatic)
> 
> what are the permissions on the /etc/cron.daily/scripts you added?  note: your cron.daily is commented out in your sample.
> ...

 

Thanks for your suggestions and help.

ssmtp was not installed/configured, I believe because when I set this server up, ssmtp & postfix blocked each other.  When I install ssmtp and run etc-config, it wants to set my MTA to be ssmtp and not postfix--I don't want this to happen as everything is working fine with Postfix for my users.  Should I have both ssmtp & postfix installed?

"find / | grep dead.letter" returns nothing

I commented out the extra variables in crontab, leaving only MAILTO so that I can continue testing.  We'll see after the cron.daily scripts run if that had any effect.

Regarding permissions on /etc/cron.daily:

```

$ ls -la /etc/cron.daily/

total 40

drwxr-xr-x  2 root root 4096 Jun 25 13:48 .

drwxr-xr-x 58 root root 4096 Jun 29 23:31 ..

-rw-r--r--  1 root root    0 Apr  8  2006 .keep

-rwxr-xr-x  1 root root   26 Sep 20  2006 chkrootkit

-rwxr-xr-x  1 root root   52 Apr 13  2007 logrotate.cron

-rwxr-xr-x  1 root root  115 Jun 25 13:48 makewhatis

-rwxr-xr-x  1 root root  418 Apr 26  2006 makewhatis.cron

-rwxr-xr-x  1 root root  152 May  3  2006 slocate

-rwxr-xr-x  1 root root 2240 Oct 29  2006 spam_check.sh

-rwxr-xr-x  1 root root 1924 Nov 24  2007 tmpwatch

-rwxr-xr-x  1 root root  259 Apr 26  2006 update_portage.cron

```

I had a test cron.daily in the crontab, there are two in the sample I provided, one is commented out, one is not.  The one that is not is the Gentoo default.

Any other ideas?  I can't let you know if these changes had any effect until tomorrow, I will post an update then.

----------

## bunder

 *Quote:*   

> I had a test cron.daily in the crontab, there are two in the sample I provided, one is commented out, one is not. The one that is not is the Gentoo default. 

 

my bad, i was tired.   :Wink: 

let us know how things turn out.

cheers

----------

## dageyra

 *bunder wrote:*   

>  *Quote:*   I had a test cron.daily in the crontab, there are two in the sample I provided, one is commented out, one is not. The one that is not is the Gentoo default.  
> 
> my bad, i was tired.  
> 
> let us know how things turn out.
> ...

 

no problem.  am i incorrect in believing i should only have ssmtp or postfix installed, not both?

----------

## bunder

seems that way, but i still have a ssmtp.conf on my mail server... not sure if its actually being used or not, couldn't say.

cheers

----------

## dageyra

Still no email from cron, but I have determined that I believe is scripts are running.  I've added a simple output script:

```

$ cat /etc/cron.hourly/echo

echo test

```

I've updated my crontab:

```

$ cat /etc/crontab

# for vixie cron

#

# $Header: /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v 1.1 2005/03/04 23:59:48 ciaranm Exp $

#

#

# Global variables

#SHELL=/bin/bash

#PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

#HOME=/

# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly

0  *  * * *     root    rm -f /var/spool/cron/lastrun/cron.hourly

#56  15  * * *  root    rm -f /var/spool/cron/lastrun/cron.daily

1  3  * * *     root    rm -f /var/spool/cron/lastrun/cron.daily

15 4  * * 6     root    rm -f /var/spool/cron/lastrun/cron.weekly

30 5  1 * *     root    rm -f /var/spool/cron/lastrun/cron.monthly

*/10  *  * * *  root    test -x /usr/sbin/run-crons && /usr/sbin/run-crons

```

But I haven't gotten anything.  Any further suggestions?

----------

## dageyra

Solved the problem.  "sendmail" didn't exist, but "sendmail.postfix" did, no idea why.  I just linked sendmail to sendmail.postfix, now I get my cron emails.

----------

## KWhat

Do not just create a link.  The issue is with mail wrapper.

Remerge net-mail/mailwrapper and read the following two bugs:

https://bugs.gentoo.org/show_bug.cgi?id=219455

https://bugs.gentoo.org/show_bug.cgi?id=220473

----------

