Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a simple shell script that runs just fine in a login shell from cron, where it doesn't run. For some reason, /usr/local/bin is not on the users path when run from cron while it is when run in a shell.

Where is the environment for cron determined?

share|improve this question

Generally, from the non-login environment established for /bin/sh, which is the default used to run the command.

You can set additional environment variables in your crontab in most versions, vis:

@reboot whatever

Check crontab(5) for details; man 5 crontab

share|improve this answer

Check which shell your script is using.

The shell and variables for crontab are specified in /etc/crontab

x@x:~$ cat /etc/crontab 


The profile file used by sh is in user home.

x@x:~$ ls ~/.profile 

You can add PATH variable in end of this file (Make sure you are adding in profile file of correct user)


or you can add the same line in your own script.

share|improve this answer

You must log in to answer this question.

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