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

5
  • Trivial typo: you have a space between * and /3. Commented Apr 7, 2019 at 5:46
  • @tripleee, I dont space. Its a typo.I corrected it now Commented Apr 7, 2019 at 5:48
  • More generally, you are expected to perform basic troubleshooting before posting. The nominated dupicate and the Stack Overflow crontab tag info page show how. If this is one of the common cases, please accept the duplicate nomination. Commented Apr 7, 2019 at 5: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. Commented Apr 7, 2019 at 5: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. Commented Apr 7, 2019 at 12:39

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

13 Comments

I added the '#!' in the begining of the script still is not executing. Also I appened the question showing the permission rights
Try executing it using the full path and see if there is any issues: ./opt/app-root/src/S3_Upload.py
By the way, the screenshot you just included shows a script with a different file name then the code you provided...
i just modified the script to append '#!'
Bubble Hacker, still doesnt work
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.