0

I have python script which I need to run with diffrent frequency within a specified time frame. I tried to do this through crontab but I do not know how to bite it :/

My time intervals and frequencies look like this (i have it more than 200):
from 2015-11-15 06:00:00 to 2015-11-15 07:00:00 every 5 min
from 2015-11-14 06:20:00 to 2015-11-14 06:32:00 every 30 sec
from 2015-11-14 18:00:00 to 2015-11-14 19:10:00 every 5 min
from 2015-11-14 11:00:00 to 2015-11-15 11:00:00 every 10 min
from 2015-11-16 12:00:00 to 2015-12-16 12:00:00 every 15 min

I work on VPS Linux with CentOS 6 64bit
This interval and frequency i have stored in MySQL
How can I do this in most efficient way?

Marcin
  • 1

1 Answers1

0

First, cron's minimum frequency is 1 minute. So to get 30s frequency, you're going to need a wrapper script that runs your job twice.

Since you're already writing a wrapper script, I'd just make it run every minute and let the script decide if it actually runs the job or if it just exits without doing anything. You could write the script in Python or other scripting language and pull data out of your database, though unless that data is going to be changing, I would hard-code the time ranges in the script to remove complexity.

EEAA
  • 109,363
  • 18
  • 175
  • 245