FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python_example/python_cron.py at main · rheehot/python_example · GitHub
rheehot
/
python_example
Public
forked from
nicecoding1/python_example
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python_example
/
python_cron.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (35 loc) · 971 Bytes
Breadcrumbs
python_example
/
python_cron.py
Copy path
File metadata and controls
45 lines (35 loc) · 971 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
time
,
os
from
datetime
import
datetime
def
save_log
(
msg
):
if
msg
==
""
:
return
now_dt
=
datetime
.
today
().
strftime
(
"%Y-%m-%d %H:%M:%S"
)
file_dt
=
datetime
.
today
().
strftime
(
"%Y%m%d"
)
with
open
(
"python_cron_"
+
file_dt
+
".txt"
,
"a"
)
as
f
:
f
.
write
(
"["
+
now_dt
+
"] "
+
msg
+
"
\n
"
)
while
True
:
now
=
time
.
localtime
()
now_list
=
list
(
now
)
hr
=
now_list
[
3
]
min
=
now_list
[
4
]
day
=
now_list
[
6
]
#monday: 0, sunday: 6
# 1min
os
.
system
(
"/usr/bin/php /home/cron/test.php"
)
save_log
(
"test.php"
)
# 2min
if
min
%
2
==
0
:
os
.
system
(
""
)
save_log
(
""
)
# 5min
if
min
%
5
==
0
:
os
.
system
(
""
)
save_log
(
""
)
# everyday 4:00 am
if
hr
==
4
and
min
==
0
:
os
.
system
(
""
)
save_log
(
""
)
# sunday 5:10 am
if
day
==
6
and
hr
==
5
and
min
==
10
:
os
.
system
(
""
)
save_log
(
""
)
time
.
sleep
(
60
)
Back
|
FazBrowse Home
|
New Git URL