Help with troubleshooting crontab

Hello all,

When I configured cron jobs that execute bash scripts a while back on my box they worked and the other day I tried to enable cron jobs that execute a bash script to run with no success.

cron text file:

test.sh file

The script has execution rights (e.g. if I use bash /usr/local/bin/sensor-rpt/test.sh) it outputs the timestamp to a file. The first job "date" outputs it's file to the tmp directory and dates are getting appended when executed by crontab.

I also tried adding my user to the crontab group and it still didn't resolve the problem. Any advice would be greatly appreciated.

It's likely the #!/usr/bash is incorrect. You'd not have a problem if you use the command line 'bash scriptname' as that invokes bash directly and #! is not examined.

I prefer this method of specifying the interpreter:

#!/usr/bin/env bash

as it allows bash (or other interpreter) to be selected based on the path and not necessarily what is installed as the default on the host -- very handy when testing etc.

Try changing the #! and if that doesn't help, change your redirection from /dev/null to a real file and see what error messages are generated.

I gave your suggestion a try with no success. I'll take a look at the FAQ post to see what I can try: cron and crontab

It's just odd because my original post worked about a month ago. I'm not certain what changed and it works on my other Ubuntu box.