Don’t forget about the environment when you use cron

The commands that are executed via cron are started in a different environment than the one you have while you test the command in a shell. The blog entry of Mike Tremell explains the reasons and gives solutions to the problem. The easiest one is to set up the correct environment in a script that you call in a crontab:

. /etc/profile
. /home/user/.profile

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.