-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbackup.py
41 lines (31 loc) · 931 Bytes
/
backup.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
import subprocess
from datetime import datetime
import time
import threading
GROUP_ID = -1001337729941
def waktu():
while True:
sekarang = datetime.now()
if sekarang.hour == 17:
pesan = 'jam 17:00'
bot.send_message(text = pesan,chat_id = GROUP_ID)
def cetak():
filename = '~/v3/timerbot31.py'
i = 0
while True:
p = subprocess.Popen('python3 '+filename, shell=True).wait()
if p != 0:
return ('restart ke {}'.format(i))
i += 1
time.sleep(2)
continue
else:
break
# Create an event to signal the threads to stop
event = threading.Event()
# Start the threads
threading.Thread(target=cetak, daemon=True).start()
# threading.Thread(target=waktu, daemon=True).start()
# Wait for the threads to finish
while not event.is_set():
time.sleep(1)