0

I have a Python script for web scraping using Selenium. In that I want to execute the script in a period of time. For that, I want to know how to schedule using crontab on Ubuntu.

Crontab is not opening the browser and executing the Selenium automation, so is there another way to schedule the Python script?

5
  • why dont you simply do crontab -e and edit the file. This is one time task Commented Nov 5, 2019 at 7:24
  • Not executing would you help to do? @YugandharChaudhari Commented Nov 5, 2019 at 7:24
  • what is your time interval? Commented Nov 5, 2019 at 7:26
  • Please use the below link as this is already answered. stackoverflow.com/questions/8727935/… Commented Nov 5, 2019 at 7:27
  • Please use the below link as this is already answered stackoverflow.com/questions/8727935/… Commented Nov 5, 2019 at 7:28

2 Answers 2

0

Run command

sudo  crontab -e

If you want to run your script every two hours,

0 */2 * * *  DISPLAY=:0 /usr/bin/python3.7 /home/monic/PycharmProjects/scrap.py

You can adjust the cron schedule from here.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use this tool to determine your cron expression.

Do

sudo  crontab -e

Choose the editor if asked nano is easier

Go to the bottom of the file use your cron expression interpretor and path to the python script like this

* * * * * /usr/bin/python /home/myuser/script.py

Above script will run every minute

Explanation

* * * * * is cron-expression 

/usr/bin/python is path to interpretor

/home/myuser/script.py is path to script

12 Comments

I did the same but not executing the script @Yugandhar Chaudhari
What is your time interval if it is too long then you should wait please post what you have done it is difficult to help without it
19 13 05 11 02 /usr/bin/python /home/monic/PycharmProjects/scrap.py
Your cron expression is wrong what is your time interval? Every day, every hour ? what is it?
It will only run At 13:19 on day-of-month 5 and on Tuesday in November.”
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.