Subject: Re: cron job not running
To: Carl Alexander <xela@mit.edu>
From: matthew sporleder <msporleder@gmail.com>
List: netbsd-users
Date: 03/31/2007 11:53:59
On 3/31/07, Carl Alexander <xela@mit.edu> wrote:
> It's been something like ten years since the last time I did
> anything involving a user crontab (as opposed to the system
> crontab, /etc/crontab). I ran, as me, crontab(1) and created
> this crontab:
>
> xela:~# crontab -l
> 55 9 * * 6 /home/xela/bin/crontest
>
> The script in question (appended below) is very straightforward.
> It's a stripped down version of the much longer script I really
> want to run from cron, but it does the main things that script
> does: write to a file in the user's homedir, and write to a file
> in /tmp, then mail that file.
>
> cron seems to just ignore it entirely; the only thing in its log
> is me editing; series of LIST, BEGIN EDIT, REPLACE, and END EDIT
> entries corresponding to each time I've edited the crontab. And
> that's it.
>
> There's something that looks deceptively like a clue in the
> cron man page:
>
> If the allow file exists, then you must be listed therein in order to
> be allowed to use this command. If the allow file does not exist but
> the deny file does exist, then you must not be listed in the deny file
> in order to use this command. If neither of these files exists, then
> depending on site-dependent configuration parameters, only the super
> user will be allowed to use this command, or all users will be able to
> use this command.
>
> Inially the machine had no allow or deny file. The fact that I
> could run crontab as xela suggested there was no "site-dependent
> configuration parameter" issue. But man pages are often so
> poorly written that I can easily imagine that "allowed to use
> this command" might really mean "allowed to run jobs out of their
> crontab". So I went hunting for some sign of that "site-dependent
> configuration", without any hints from the man page as to where it
> might be hidden. I found nothing in /etc, nothing in /var/cron,
> and then gave up and created a /var/cron/allow with me in it. Ran
> crontab -e, changed the time to about ten minutes in the future,
> waited to see if it ran. And when it didn't, started this mail.
>
> Any and all clues greatly appreciated.
>
> ---Alex
>
> Here's the stripped-down script I'm asking it to run (slightly
> edited for posting here: see $DOMAIN). Note that I have also
> tried a varient where $HOME and $USER were hard-coded, in case
> cron's environment is more cripled than I think.)
>
Try this:
* * * * * touch ~/foo
If that works, you should get a foo file in your home directory and
your script is the problem.
If it doesn't work, make sure cron is running and that /var/cron/allow
is being read. (you might need to restart/HUP cron)