Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my Mac (yeah, yeah I know. but my Linux box is at work) for some reason cron and at don't want to work. They both register that jobs have been added, with no syntax errors or any qualms at all. Then the time passes, and neither do anything.

52 18 * * * username touch ~/webserver/AAAAA

That should have run at 6:52PM PST, but it never did. Why?

For at, I did: at 6:48 pm < jobs where jobs looks like:

touch ~/webserver/AAAAA

And nothing happened. Thoughts?

share|improve this question

migrated from Jan 13 '12 at 3:21

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

Have you looked in your mailbox with mail? You will probably find error messages from cron there. I found my expected error when I set cron going before I created the script for it to run. One useful bit of information was the environment settings - which are often relevant to these problems. I got the information:

Message 1:
From jleffler@Isis.local  Thu Jan 12 20:16:01 2012
X-Original-To: jleffler
Delivered-To: jleffler@Isis.local
From: jleffler@Isis.local (Cron Daemon)
To: jleffler@Isis.local
Subject: Cron <jleffler@Isis> /bin/ksh /Users/jleffler/bin/Cron/minutely
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=jleffler>
X-Cron-Env: <USER=jleffler>
X-Cron-Env: <HOME=/Users/jleffler>
Date: Thu, 12 Jan 2012 20:16:00 -0800 (PST)

/Users/jleffler/bin/Cron/minutely[15]: exec: /work1/jleffler/bin/minutely: not found

This from an entry:

*        *       *       *       *       /bin/ksh /Users/jleffler/bin/Cron/minutely

The other issue I see is your command line:

52 18 * * * username touch ~/webserver/AAAAA

What is the username command? It isn't something I find on my Mac (MacOS X 10.7.2). Is it in /usr/bin or /bin on your machine? If not, the chances are high that it won't be found.

The /Users/jleffler/bin/Cron/minutely script on my machine is a (symlink to a) script that reads a profile - I call mine .cronfile - and then executes a command /Users/jleffler/bin/minutely, all based on the basename of the file in the Cron directory. This sets my PATH to something more useful than the system PATH provided by cron.

share|improve this answer
Oh that's interesting! And for some reason my cron manpage says to put my username in that field. Thank you for answering! What about at? – tekknolagi Jan 13 '12 at 4:26
For the format of crontab entries, try man 5 crontab. – Jonathan Leffler Jan 13 '12 at 4:54
@tekknolagi: For 'at', I note that man at includes: IMPLEMENTATION NOTES Note that at is implemented through the launchd(8) daemon periodically invoking atrun(8), which is disabled by default. See atrun(8) for information about enabling atrun. When I tried on my system, at queued the job OK, but the jobs did not run. That was when I really read the man page! (When I did what man atrun said, my previously queued at requests ran at the next minute boundary.) – Jonathan Leffler Jan 13 '12 at 5:04
Thank you JonathanLeffler! seems you also helped me on my Perl code :) – tekknolagi Jan 13 '12 at 6:53

My bet - is that the path for cron is not inclusive enough to include touch - either add a path directive to the cron or use a fully qualified path for touch

share|improve this answer
Okay, just tried with /Users/username/webserver/ instead of the ~ path but that doesn't work either. Why? – tekknolagi Jan 13 '12 at 3:17
So what's wrong? :( – tekknolagi Jan 13 '12 at 3:25
Not sure about Mac but un9's have a /var/log/cron.log file which may have more info – Adrian Cornish Jan 13 '12 at 3:27
No such file :( – tekknolagi Jan 13 '12 at 3:29
Sorry - out of ideas - hopefully expert here can help – Adrian Cornish Jan 13 '12 at 3:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .