Dhruv Shah
Dhruv Shah

Reputation: 45

How can I run a Python script on a server at a given time on all the days?

I can keep a Python script running all the time with a specific delay time but that looks too silly as it keeps on using the system that too being idle so whats the solution?

Upvotes: 1

Views: 142

Answers (1)

Ulf Aslak
Ulf Aslak

Reputation: 8608

Use cron. On command line it's crontab -e to open a vim editor where you can schedule things to run. Here's the documentation. So to run a script every minute ever with cron you would add this line to your crontab:

* * * * * python <path to>/script.py

First * is every minute, but could eg be a number between 0 and 59 to run once an hour, second * codes for hour of day, third is day of month and so on.

Upvotes: 2

Related Questions