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 have a script that works perfectly if I execute it from the command line manually. However, when it runs via cron, the job fails with the following error:

/usr/bin/env: escript: No such file or directory

The first line in the script is:

#!/usr/bin/env escript

The only thing I can figure is that escript is not being found, and that is because it is not installed in /usr/bin, but in a sub-directory of the user's home directory.

My understanding--perhaps misunderstanding--of cron is that cron runs each job in a user's crontab under the UID/GID of the user. Should it also not inherit the PATH variable from the user as well? Must everything be specified as absolute paths?

share|improve this question
up vote 1 down vote accepted

Cron runs under the UID of the user but with a minimal PATH. Your script needs to use a full path to the interpreter (escript) or you need to set the PATH in the crontab.

share|improve this answer

cron does not inherit the PATH from the users's interactive setup. PATH is set to "/usr/bin:/bin"

Ypu can set environment variables on the crontab line

See man crontab for the details e.g. man crontab

share|improve this answer

You must log in to answer this question.

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