July 14, 2011

Vixie Cron How I Loath Thee.....

As some know, I work as the senior systems administrator for a company in the southeast SF Bay Area. Recently, we had to move to a new security system, after having been broken into four times in the last _four_ years.

One of the features of this new system is that it ties into our phone system to alert the building that the alarm is about to be armed. To do this, a dial out to a special phone number needs to occur at the desired hour and then voila! Instant Alert throughout our suite! So, we've setup an email to fax service that we can easily trigger by a simple email.

So I wrote a REALLY simple shell script shown below (with the fax and email addresses elided):


set -e

echo "Sending Security Page NOW!"

/usr/sbin/sendmail -t <<EOF
FROM: SOMERANDOMSMUCK@minervanetworks.com
TO: 1234567890@fax.com
CC: SOMERANDOMSMUCK@minervanetworks.com
SUBJECT: Alarm Set



if [ $? -eq 0 ]; then
echo "SUCCESS"

As I said, simple.

From there I setup my crontab on one of the Linux box in my cube to have it go off at the apropriote time, 7:55PM Monday through Friday:


50 19 * * 1-5 /usr/bin/securityfax.sh

Tested out the script, thinking that "Hey, I'm all done". Wrong.

I come to find out that Vixie Cron can't seem to tell time! I get the alert emails at 8:31PM from the system!

At this point, looks like I'll be replacing Vixie Cron on my workstation (CentOS 5). Can anyone advise a good Cron Daemon replacement that has enough similarities to vixie cron that I won't have to relearn too much and can actually interpret time settings in the crontab as more than mere suggestions?


  1. Are you sure? Is the time on your WS correct? Are you sure that any intermediairy mailserver is relaying outgoing mail immediately as opposed to once every so many minutes? Can you add a timestamp in the email you're sending?

  2. 55 7 * * 1-5 echo "fu"

    Try this one.

  3. It's interesting, because just yesterday I was finally setting up rolling daily backups of my laptop, workstation and a personal server I run, using rsnapshot. First time in a long time since I dabbled with cron, but when looking this morning everything seems to have worked like clockwork:

    server /var/log/rsnapshot:
    [15/Jul/2011:03:01:00] /usr/local/bin/rsnapshot daily: started

    laptop /var/log/rsnapshot:
    [15/Jul/2011:03:00:03] /usr/bin/rsnapshot daily: started

    workstation /var/log/rsnapshot:
    [15/Jul/2011:03:00:01] /usr/bin/rsnapshot daily: started

    The laptop and workstation are running Dillon cron (Arch Linux), but the server is an ancient FreeBSD 7.0 install running Vixie Cron. It was set to go off at 03:01 AM and as you can see it seems to have gone of exactly then, on the second.

    I also think something else in the setup except cron must be the problem.

  4. Ruurd: Positive. We use LDAP+Kerberos for auth, which is extremely time sensitive, so we have NTP running on all systems at work. Additionally, the only mail server my box routes through is the single exgress SMTP box for the company.

    Regarding adding a time stamp, I *can*, however I'm not seeing how that can help, as the email is also CC'd directly to me as it passes through the SMTP server (an Exchange box who's clock is synced to our DCs, which are in turn synced against tick and tock of the USNO.

  5. Not possible. Vixie always executes at that time (even anacron isn't that inaccurate).... Add a datestamp into the mail indeed. Check the syslog if the script is executed and see if the mail doesn't get queued on your server.

  6. I'm using Vixie Cron from years in my CentOS servers and and I've never seen the problem you are experiencing. I'm pretty sure that Vixie Cron is not guilty here :-).

  7. I'd suggest FCron — it does everyhing that Vixie (or any other standard cron) does plus what AnaCron does plus a few more things :]

    The basic idea behind FCron is that not all boxes run 24/7 (e.g. laptops, desktops etc.) and there should be a solution for that.

    The commands in FCron that do the same as Vixie does are basically the same, so you shouldn't have too work figuring it out.

    I wrote a small howto about it as well:

  8. Yeah, I do a lot with cron jobs that need to run at very specific times (healthcare) and I have never seen it not run at the correct time. Sounds like something else is interfering.

  9. You're doing something wrong. I have never seen cron triggering at the wrong time, and the company I work for has millions of pounds worth of business depending on cron triggering at the right time. And it does.

  10. I'll add my voice to the chorus. The problem isn't cron. Either there's a delay in your mail transmission, your script blocking on input or taking a long time to process, or there's a timing problem on your workstation.