Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Ubuntu system that has anacron installed. However I'm pretty sure it's not running. It's not running the commands in /etc/cron.daily to rotate the syslog files (I'm using sysklog, which has its own rotating log method, not using logrotate). The last time the logs were rotated were in October 2009. /var/spool/anacron/cron.daily exists and the contents are 20091015. AFAIR we had a power outage then, and everything rebooted.

How can I debug anacron? How can I see why it's not running? My first instinct is to look for /var/log/anacron, but that's not there. How can I fix it to make it run again?

share|improve this question

6 Answers 6

up vote 4 down vote accepted

Look at the following:

zgrep anacron /var/log/cron.log.{9..1}* /var/log/cron.log | less

The last entry on one system for me is November 4, 2008.

zgrep anacron /var/log/syslog.{9..1}* /var/log/syslog | less

The entries range from December 28 through January 4 for me.

cat /etc/crontab

You should see entries similar to this for daily, weekly and monthly:

25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

And this should show a bunch of files:

ls -l /etc/cron.{daily,weekly,monthly}

In /etc/cron.daily I have both logrotate and sysklogd.

And if you do:

ps auxww | grep [c]ron

you should see that the cron daemon is running.

If you do:

cat /etc/cron.daily/sysklogd

you should see a few lines that end in || exit 0 - check to make sure that the files exist and, for the ones with test -x that they are executable. Some of them don't for me since I'm using logrotate.

Check to see if syslogd is running:

ps -C syslogd

See if savelog exists and is executable:

ls -l $(type -p savelog)

That's all I can think of at the moment.

share|improve this answer
4  
Plus remember that anacron is essentially just config for cron, so it's not a daemon –  LapTop006 Jan 5 '10 at 11:17

Try restarting the service, does that give you an error?

share|improve this answer

I have an ubunutu 8.04 vps (w/plesk) that had anacron installed, mis-configured, and not running. apt-get reinstall recreated all the relevant files.

After which, all I had to do was add an entry to the hourly crontab to fire up anacron and have it do its work.

the script I put in cron.hourly/ was just

#!bin/bash
/path/to/anacron -s 
share|improve this answer

Some of the Linux crons are flaky. We use cfengine to restart cron, and cron to watch cfengine for mission critical stuff. These days, neither one crashes noticably though. Not like in the 90's when cron was crashing ever day :-)

share|improve this answer

Try running :

sudo run-parts --test /etc/cron.daily

That line will tell if your new script is among the ones "recognised". For instance it could be that the script has a wrong name, exec flag is missing or permisission issues etc.

I found out this way that the run-parts tool (used by cron) do not like a .sh suffix

share|improve this answer
    
Surprised to learn about the .sh danger, thanks! –  Marcos May 28 at 20:33

It the name of the script in the /etc/cron.{daily,weekly,monthly}/ folder has a dot in it, it seems to not execute. Try to rename it to something without a dot in it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.