1

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.

fixer1234
  • 28,064
orion3
  • 722

3 Answers3

5

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.

BenjiWiebe
  • 9,173
1

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

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

Removing it from crontab fixed the issue.

orion3
  • 722
-3

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
Stephan
  • 346