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 this in my crontab:

PATH=/usr/bin:/usr/local/bin:$PATH
*/1 * * * * /usr/bin/env bash > ~/cron.log 2>&1

The ouput in cron.log is the following:

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

/usr/bin/env as well as /bin/bash both exist. And I can also run this command from the same user to whom this crontab belongs without any errors. I also tried adding

SHELL=/bin/bash

to the top of the crontab. No effect. Don't have a clue what's going on. Also this:

*/1 * * * * which bash > ~/cron.log 2>&1

shows nothing at all in the log file. This is everything I have in my crontab for this user, nothing else.

share|improve this question
    
Is that a typo, in your last example, shouldn't it read `which bash`, instead of which bash? –  BenjiWiebe Feb 15 '13 at 2:05

3 Answers 3

Since your script that cron runs starts with #!/usr/bin/env bash (right?), all you need to do in your crontab is:

*/1 * * * * /path/to/script > ~/cron.log 2>&1

And make sure that the script actually outputs something; if your script is completely quiet, your log file will be empty.

share|improve this answer

Turns out, I shouldn't have had this line:

PATH=/usr/bin:/usr/local/bin:$PATH

Removing it from crontab fixed the issue.

share|improve this answer

Am not sure what exactly you're trying to do, but for me:

# which bash
/bin/bash

So try

/usr/bin/env /bin/bash /path/to/some/script > ~/cron.log 2>&1
share|improve this answer
    
One of the scripts that I run with cron (rvm-exec) has #!/usr/bin/env bash at the top of it and I can't really change it, because it breaks everything. I realized that the problem in this particular case is with cron, not rvm, since cron doesn't even know where bash is. –  snitko Feb 15 '13 at 0:52
3  
It completely defeats the purpose to use /usr/bin/env /bin/bash; /usr/bin/env searches the PATH for bash; you use /usr/bin/env to find bash when you are not sure where bash is at. –  BenjiWiebe Feb 15 '13 at 2:04

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.