Run-parts vs. user crontab execution


Revision as of 16:43, 30 April 2008 by Hutch (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

One caveat when running programs via run-parts (e.g., /etc/cron.hourly, /etc/cron.daily, etc.) vs. user crontabs is the HOME environment variable.

By default, HOME is set to / in /etc/crontab. Without a HOME line in user crontabs, HOME is the home directory in /etc/passwd of the crontab owner.

This caused me problems when I tried to execute a MySQL backup script via run-parts that depended on ~/.my.cnf in the user's home directory. As a workaround, I modified the script to set the HOME environment variable rather than make a global change in /etc/crontab for all run-parts scripts.

Personal tools