1

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?

0

2 Answers 2

1

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 [email protected]  Thu Jan 12 20:16:01 2012
X-Original-To: jleffler
Delivered-To: [email protected]
From: [email protected] (Cron Daemon)
To: [email protected]
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.

4
  • 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, 2012 at 4:26
  • For the format of crontab entries, try man 5 crontab. Jan 13, 2012 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.) Jan 13, 2012 at 5:04
  • Thank you JonathanLeffler! seems you also helped me on my Perl code :)
    – tekknolagi
    Jan 13, 2012 at 6:53
1

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

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

You must log in to answer this question.

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