1

i am trying to run a selenium python script regularly with display, although the script is not executed. Running dummy jobs shows that cron works although the same does not apply to python3//selenium script. My crontab -l output:

SHELL=/bin/bash
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday;
# │ │ │ │ │                                       7 is also Sunday on some systems)
# │ │ │ │ │
# │ │ │ │ │
# * * * * *  command_to_execute

12 18 * 5-8 1-5 export DISPLAY=:0; /Users/eshauchuk/opt/anaconda3/bin/python3 /Users/eshauchuk/checkout.py

12 18 * 5-8 1-5 /Users/eshauchuk/opt/anaconda3/bin/python3 /Users/eshauchuk/checkout.py

Besides mentioning that scripts should be run in bash and specified the need for Display although no luck so far. Would be grateful for any help!

euh
  • 319
  • 2
  • 11
  • Just curious. Have you tried putting the commands into a script file? How would you handle it with a virtual env? (I know that you already solved your problem) – Martin Müsli Jul 31 '21 at 13:22
  • 1
    Oh, that's interesting even though over my head. You could probably something like that https://stackoverflow.com/a/56793448/13158157 – euh Aug 01 '21 at 15:32

1 Answers1

1

solved by specifying both DISPLAY and PATH:

* * * * * export DISPLAY=:0 && export PATH=$PATH:/usr/local/bin && /Users/username/opt/anaconda3/bin/python3 /Users/username/checkout.py >> crontab.txt

using anaconda's python

euh
  • 319
  • 2
  • 11