Re: Command not running in crontab

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Jim Perrin wrote:
On 3/23/07, Mário Gamito <gamito@xxxxxxxxx> wrote:
Hi,

Can anoyone tell me why this command is not executed (or it is without
success) from crontab, but works perfectly from the command line ?
(yes, i've restarted crontab service)

It works from the command line? that's kind of surprising. It may work
via tab completion in the shell, but will not work with that as typed.
You'd suffer from shell expansion.
??


# clean up postmaster
00 30 * * * root /usr/bin/find
/var/qmail/maildirs/postmaster@xxxxxxxxx/Maildir/new -type f -print0 |
xargs -0 -n 50 rm

You very likely need to escape the @ as the shell is probably trying
to do something with it.



It's true that, using tab-completion, the @ can get escaped, but I can't find that bash actually does anything with it in this context:
[summer@bilby ~]$ mkdir /tmp/x@j
[summer@bilby ~]$ mkdir /tmp/x\@j/
The second, I used tab-completion to expand from "/tmp/x." As you can see, it was used as typed.

I would first, check the logs.

I generally use the user's crontab, so
crontab -e
and ensure I have a line
MAILTO=me@xxxxxxxxxxx
so I get the results mailed to me. It's good to set PATH too.

I also have had bad experiences (one day I will complain to someone's bugzilla) with crond eating stuff. This does not work:
0 * * * * echo $(date)

The workaround is to put the command(s) into a script.


--

Cheers
John

-- spambait
1aaaaaaa@xxxxxxxxxxxxxxxx  Z1aaaaaaa@xxxxxxxxxxxxxxxx

Please do not reply off-list
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux