0

I have created a script

#!/bin/bash
 echo "tredor"

If I run it using command line, it works, but when I move it to being a cron job, it doesn't.

In crontab -e , I entered the following code

*/5 * * * *  root ./my_script

I expect to see an output "tredor" every 5 minutes but that is no happening. How can I modify my codes to be able to see output?

Seth
  • 59,332
sosytee
  • 2,738

1 Answers1

2
  • Use the full path to your script in the crontab
  • make sure it is executable: sudo chmod +x my_script
  • You got the path to the interpreter wrong in the first line of your script: it should be #!/bin/bash
  • As steeldriver pointed out, you won't actually see any output
  • Since you used 7 columns for your cronjob, I assumed you used a system wide crontab (in the /etc/cron* dirs or /etc/crontab. Using crontab -e edits your user specific crontab!
phoibos
  • 22,176