-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
updatecron.py
33 lines (26 loc) · 904 Bytes
/
updatecron.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
from crontab import CronTab
import db
user_cron = CronTab(user='pi')
def listCron():
for job in user_cron:
print(job)
def updateCheckFrequency(comment, freq, enabled):
for job in user_cron:
if job.comment == comment:
job.minute.every(freq)
if enabled == '1':
job.enable()
else:
job.enable(False)
user_cron.write()
print(comment + " cron job updated successfully. It will now run every " + str(freq) + " minutes")
def updateCron(comment, val, enabled):
for job in user_cron:
if job.comment == comment:
job.setall(val)
if enabled == '1':
job.enable()
else:
job.enable(False)
user_cron.write()
print(comment + " cron job updated successfully. The new cron value is: " + str(val))