Cron

Crontab

Troubleshooting Crontab Problems

Dump the Environment

add this line to root’s crontab

* * * * * env > /root/cronenv

Load the Environment

env - $(cat /root/cronenv) /bin/sh

Run your script

./script_with_env_problems.sh

and check it’s output …


Any Comments ?

sha256: de1667fb4003135420244f48280d72e03d7559b675ab6b4a9c020b0725866525

Cron & Environment

Sometimes you run into problem because you’re not aware of the environment of cron.

So, let’s dump and check the environment.

Add Cronjob

*       *       *       *       *       env > /tmp/env.log

Dump Content

puffy200# cat /tmp/env.log
LOGNAME=root
HOME=/var/log
PWD=/var/log
PATH=/bin:/sbin:/usr/bin:/usr/sbin
SHELL=/bin/sh
USER=root

Any Comments ?

sha256: 6e5d4767a577cc5673505edd19b29f931ce23de7f97a9088c3137945206730a3