I've experienced an issue where some of my scripts run perfectly fine when I call them manually, but these same scripts when called as cron jobs via cron don't seem to work at all.

So my question: I'd like to know if there are restrictions that apply with the use of commands and/or scripts (and the privilege of execution) in a script scheduled to run with cron?

  • How are you setting these cron jobs up? Using crontab -e as a user or are you adding them to your system's /etc/cron* directories and/or files?
    – slm
    Jan 7, 2014 at 10:21
  • I use the crontab command..
    – rusty
    Jan 7, 2014 at 14:57
  • 1
    OK, so the cron jobs you're setting up are running as your userid, so the only thing you have to deal with is a difference in environments when running the script vs. running it in a cron. I believe you can also do this to get a Bash environment up and running via your crontab. unix.stackexchange.com/questions/94456/…
    – slm
    Jan 7, 2014 at 15:15

1 Answer 1


The most common reason why commands that work fine from the command line would fail under cron is the fact they run under a stripped down environment with only a handful of variables defined.

In particular PATH is set to its default value.

Any customization done in dot files (.profile /etc/profile and the likes) is not done with cron scripts but of course, this can be fixed by modifiying the cron entry or the called script itself.

The fact the script is non interactive and missing a graphic environment (DISPLAY variable) might also affect scripts to run as expected.

Not the answer you're looking for? Browse other questions tagged .