-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmycronfile.py
45 lines (38 loc) · 1.15 KB
/
mycronfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from crontab import CronTab
# Get the current list of cron jobs
cron = CronTab(user=True)
# Go through the list looking for the one we want to change
def schedulingaturn(mins, hours, dom, m, dow):
for job in cron:
if 'scheduleturn.py' in job.command:
#print "HELLO?:", job
minutes = mins
hours=hours
day_of_month=dom
month=m
dow=dow
schedule = "{0} {1} {2} {3} {4}".format(minutes, hours, day_of_month, month, dow)
print schedule
job.setall(schedule)
#job.dow.on()
else:
print "nope"
cron.write()
def schedulingawater(mins, hours, dom, m, dow):
for job in cron:
if 'schedulewater.py' in job.command:
#print "HELLO?:", job
minutes = mins
hours=hours
day_of_month=dom
month=m
dow=dow
schedule = "{0} {1} {2} {3} {4}".format(minutes, hours, day_of_month, month, dow)
print schedule
job.setall(schedule)
#job.dow.on()
else:
print "nope"
cron.write()
#schedulingaturn('0', '0', '*/3', '*', '*')
#schedulingawater('0', '0', '*/5', '*', '*')