Newbie question: Why aren't my cron jobs running?
Robert Bonomi
bonomi at mail.r-bonomi.com
Tue Jun 12 05:05:42 UTC 2012
Walter Hurry <walterhurry at gmail.com> wrote:
>
> As the subject says, this is probably a newbie question (I am new to
> FreeBSD but quite experienced at Linux).
>
> FreeBSD9 on x86_64.
>
> Cron is running:
>
> $ ps -ax|grep cron
>
> 1513 ?? Is 0:00.01 /usr/sbin/cron -s
>
> 2283 0 S+ 0:00.00 grep cron
>
> $
>
> I have a syntactically valid crontab:
'Syntactically valid', yes, but I believe "it does not mean what you think
it does" applies. more below.
> $ crontab -l
> #min hr dom month dow command
>
> SHELL=/bin/bash
>
> PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/
> daddy/bin
>
> HOME=/home/walterh
>
> 00 02 * * * /home/walterh/exports.sh
>
> 05 02 * * * /home/walterh/backup_etc.sh
>
> 10 02 * * * /home/walterh/systemcheck.sh
>
> 15 02 * * * /home/walterh/backup_bsd.sh
>
> $
>
> So what is wrong? Why is nothing happening? I have consulted the handbook
> but see nothing.
It _appears_ that there is whitespace _before_ the purporte 'minutes' value
on each line that you intend to invoke a command. If so, -THAT- is probably
what is causinng the unexpected behavior. I believe cron is looking for
the 'minutes' value _before_ any white space, and using a value of '0' when
it finds 'nothing' before the white-space Field-separator. That, thus,
the all the commands run at 'zero minutes' past the various hours, on the
-second- day of the month, and that command-line that cron would -attempt-
to execute on the 2nd looks like, "* /home/walterh/systemcheck.sh", which,
of course will have *wildly* unexpected results, epecially if the first
element of the '*' expansion _is_ marked as executable.
Remove the leading white-space and things should work the way you 'expect'.
Comment: using a leading zero on the numeric fields is a BAD IDEA(tm) -- you
are *strongly* encocuraged to remove them. Yes, that means numbers will not
be column aligned, but it is a small price to pay to avoid the hair-tearing
that =will= ensue when using it bites you.
More information about the freebsd-questions
mailing list