-1

I've tried setting up Crontab for the first time using the below:

* * * * * cd /Users/alexlee/PycharmProjects/pythonProject1 && /usr/bin/python C19 Webscrape.py

however the script isn't running. I've given permissions full disk access to Terminal and Cron but that didn't do the trick.

Any suggestions?

mosc9575
  • 5,618
  • 2
  • 9
  • 32
alexgelee
  • 1
  • 1
  • what is the name of the python file? – qmeeus Feb 18 '21 at 08:20
  • The duplicate has the collected wisdom on "any suggestions". If you have done all the troubleshooting suggested in those answers and still can't figure this out, please [edit] to indicate what debugging efforts you have done and where you are stuck. With the information you have provided, it's unclear how you are even concluding that the script isn't actually in fact running. – tripleee Feb 18 '21 at 08:25

1 Answers1

-1

Crontab takes shell commands only.

If you want to run a python script, write a shell script to run the python script within it. Use the shell script in the crontab.

For example the following can be a shell script:

#!/bin/sh
# launcher.sh
# print Hello World!

sudo python /<location-here>/hello.py

This could be your python code:

# hello.py
print("Hello World!")

I found a post which helped me start with Crontab: https://linuxize.com/post/scheduling-cron-jobs-with-crontab/

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    cd and python are shell programs, cron will be able to run them. This is not the problem ;-) – qmeeus Feb 18 '21 at 08:23