Absolute path should be used for scripts:
For example, /bin/grep
should be used instead of grep
:
# m h dom mon dow command0 0 * * * /bin/grep ERROR /home/adam/run.log &> /tmp/errors
Instead of:
# m h dom mon dow command0 0 * * * grep ERROR /home/adam/run.log &> /tmp/errors
This is especially tricky, because the same command will work when executed from shell. The reason is that cron
does not have the same PATH
environment variable as the user.