Run cron jobs with environmental variables for an account

A common error for configuring cron is to use environmental variables for an account in the cron command. However, cron will run the commands without these variables defined.

asked Aug 19, 2013 by anonymous

1 Answer

 
Best answer

In the crontab -e, adding . $HOME/.profile before the commands play the trick. For example:

0 */8 * * * . $HOME/.profile; ~/bin/my-command

Cron is started by the system with a minimal environment. Hence, you need to add all other things that you need in your script.

answered Aug 19, 2013 by anonymous

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...