-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_cron_job_logger.py
39 lines (32 loc) · 1.22 KB
/
setup_cron_job_logger.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
from crontab import CronTab
cmds = 'python3 /home/pi/KiosSehat/logger_kiossehat.py'
def removeJob(user_id, comment_id):
my_cron = CronTab(user=user_id)
for job in my_cron:
if job.comment == comment_id:
my_cron.remove(job)
my_cron.write()
def createJob(user_id, comment_id,hour_every,hour_everyset, cmds):
my_cron = CronTab(user=user_id)
jobCommentList = []
for job in my_cron:
if job.comment == comment_id:
print("You have include the cronJob")
jobCommentList.append(job.comment())
if comment_id not in jobCommentList:
job = my_cron.new(, comment = comment_id)
def updateJob_On_Zero(hour_on, hour_onset,hour_every, hour_everyset,comment_id):
my_cron = CronTab(user=user_id)
for job in my_cron:
if job.comment == comment_id:
if hour_on == True:
job.hour.on(hour_onset)
job.minute.on(0)
my_cron.write()
elif hour_every == True:
job.hour.every(hour_everyset)
job.minute.on(0)
my_cron.write()
job = my_cron.new(command='python3 /home/pi/KiosSehat/logger_kiossehat.py', comment = comment_id)
job.hour.every(17)
job.