MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / del_crontab

Method del_crontab

class/projectModel/nodejsModel.py:2256–2273  ·  view source on GitHub ↗

@name 删除项目日志切割任务 @auther hezhihong<2022-10-31> @return

(self, name)

Source from the content-addressed store, hash-verified

2254 # 日志切割 |
2255 #—————————————
2256 def del_crontab(self, name):
2257 """
2258 @name 删除项目日志切割任务
2259 @auther hezhihong<2022-10-31>
2260 @return
2261 """
2262 cron_name = f'[勿删]Node项目[{name}]运行日志切割'
2263 cron_path = public.GetConfigValue('setup_path') + '/cron/'
2264 cron_list = public.M('crontab').where("name=?", (cron_name, )).select()
2265 if cron_list:
2266 for i in cron_list:
2267 if not i: continue
2268 cron_echo = public.M('crontab').where("id=?", (i['id'], )).getField('echo')
2269 args = {"id": i['id']}
2270 import crontab
2271 crontab.crontab().DelCrontab(args)
2272 del_cron_file = cron_path + cron_echo
2273 public.ExecShell("crontab -u root -l| grep -v '{}'|crontab -u root -".format(del_cron_file))
2274
2275
2276 def add_crontab(self, name, log_conf, python_path):

Callers 1

remove_projectMethod · 0.95

Calls 8

DelCrontabMethod · 0.80
crontabMethod · 0.80
ExecShellMethod · 0.80
selectMethod · 0.45
whereMethod · 0.45
MMethod · 0.45
getFieldMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected