0

I am trying to schedule a python script using crontab to run every three minutes. It's not executing as per schedule set.

When I try to execute the script from the centos terminal it's working properly. How to fix this.

Location of my script

/opt/app-root/src/S3_Upload_V1.py

Location of crontab /usr/bin/crontab

My scheduling code

*/3 * * * * /opt/app-root/src/S3_Upload_V1.py

The script executes independently from the terminal but not from the crontab schedule. How to fix this?

enter image description here

Bubble Hacker
  • 6,425
  • 1
  • 17
  • 24
aeapen
  • 871
  • 1
  • 14
  • 28
  • Trivial typo: you have a space between `*` and `/3`. – tripleee Apr 07 '19 at 05:46
  • @tripleee, I dont space. Its a typo.I corrected it now – aeapen Apr 07 '19 at 05:48
  • More generally, you are expected to perform basic troubleshooting before posting. The nominated dupicate and [the Stack Overflow `crontab` tag info page](/tags/crontab/info) show how. If this is one of the common cases, please accept the duplicate nomination. – tripleee Apr 07 '19 at 05:52
  • ,.. And if not, please [edit] your question to include useful diagnotics, i.e. that you have checked the regular logs and your email inbox; you get an error message somewhere, we need to see it. – tripleee Apr 07 '19 at 05:57
  • @ashokeapen I SEE that you took my advice to use `cron` as cited in my answer to your previous question on using `schedule` to execute a script -- every workday (monday to friday) at 8 PM CET. – Life is complex Apr 07 '19 at 12:39

1 Answers1

0

A possible cause can be the permissions. You should make sure the file has execution permission. You can do this by running the following:

chmod u+x /opt/app-root/src/S3_Upload.py

You Should also make sure there is a "shebang" (#!) in the beginning of your script:

#!/usr/bin/env python3
Bubble Hacker
  • 6,425
  • 1
  • 17
  • 24