|
|
|
@ -13,6 +13,26 @@ import core.mw as mw |
|
|
|
|
from utils.crontab import crontab |
|
|
|
|
from croniter import croniter |
|
|
|
|
from datetime import datetime |
|
|
|
|
import thisdb |
|
|
|
|
|
|
|
|
|
def cron_todb(data): |
|
|
|
|
# print("------") |
|
|
|
|
rdata = {} |
|
|
|
|
if data[3] == "*" and data[2] != "*" : |
|
|
|
|
rdata['type'] = 'month' |
|
|
|
|
elif data[3] == "*" and data[4] != "*" : |
|
|
|
|
rdata['type'] = 'week' |
|
|
|
|
elif data[3] == "*" and data[4] == "*" and data[2] == "*" : |
|
|
|
|
rdata['type'] = 'day' |
|
|
|
|
elif data[1].find("/") > -1 : |
|
|
|
|
rdata['type'] = 'hour-n' |
|
|
|
|
elif data[0].find("/") > -1 : |
|
|
|
|
rdata['type'] = 'minute-n' |
|
|
|
|
|
|
|
|
|
# print(rdata) |
|
|
|
|
# print(data) |
|
|
|
|
return rdata |
|
|
|
|
# print("------") |
|
|
|
|
|
|
|
|
|
# 识别linux计划任务 |
|
|
|
|
def init_cron(): |
|
|
|
@ -34,15 +54,36 @@ def init_cron(): |
|
|
|
|
if cron_line.startswith("#"): |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
cron_expression = cron_line.split(maxsplit=5)[0] # 提取前 5 个字段(* * * * *) |
|
|
|
|
cron_expression = cron_line.split(maxsplit=5) # 提取前 5 个字段(* * * * *) |
|
|
|
|
command = cron_line.split(maxsplit=5)[5] # 提取命令部分 |
|
|
|
|
|
|
|
|
|
# 面板计划任务过滤 |
|
|
|
|
if command.startswith("/www/server/cron"): |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
if command.startswith("\"/root/.acme.sh\""): |
|
|
|
|
# print(cron_expression, command) |
|
|
|
|
info = cron_todb(cron_expression) |
|
|
|
|
|
|
|
|
|
# print(info) |
|
|
|
|
|
|
|
|
|
# add_dbdata = {} |
|
|
|
|
# add_dbdata['name'] = "ACME" |
|
|
|
|
# add_dbdata['type'] = data['type'] |
|
|
|
|
# add_dbdata['where1'] = data['where1'] |
|
|
|
|
# add_dbdata['where_hour'] = data['hour'] |
|
|
|
|
# add_dbdata['where_minute'] = data['minute'] |
|
|
|
|
# add_dbdata['save'] = "" |
|
|
|
|
# add_dbdata['backup_to'] = "" |
|
|
|
|
# add_dbdata['sname'] = "" |
|
|
|
|
# add_dbdata['sbody'] = data['sbody'] |
|
|
|
|
# add_dbdata['stype'] = "toShell" |
|
|
|
|
# add_dbdata['echo'] = command |
|
|
|
|
# add_dbdata['url_address'] = '' |
|
|
|
|
|
|
|
|
|
# thisdb.addCrontab(add_dbdata) |
|
|
|
|
|
|
|
|
|
print(command) |
|
|
|
|
# print(command) |
|
|
|
|
|
|
|
|
|
# cron_list = content.split("\n") |
|
|
|
|
# print(cron_list) |