Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.