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

Method del_crontab

class/projectModel/pythonModel.py:2856–2873  ·  view source on GitHub ↗

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

(self, name)

Source from the content-addressed store, hash-verified

2854 # 日志切割 |
2855 # —————————————
2856 def del_crontab(self, name):
2857 """
2858 @name 删除项目日志切割任务
2859 @auther hezhihong<2022-10-31>
2860 @return
2861 """
2862 cron_name = '[勿删]Python项目[{}]运行日志切割'.format(name)
2863 cron_path = public.GetConfigValue('setup_path') + '/cron/'
2864 cron_list = public.M('crontab').where("name=?", (cron_name,)).select()
2865 if cron_list:
2866 for i in cron_list:
2867 if not i: continue
2868 cron_echo = public.M('crontab').where("id=?", (i['id'],)).getField('echo')
2869 args = {"id": i['id']}
2870 import crontab
2871 crontab.crontab().DelCrontab(args)
2872 del_cron_file = cron_path + cron_echo
2873 public.ExecShell("crontab -u root -l| grep -v '{}'|crontab -u root -".format(del_cron_file))
2874
2875 def add_crontab(self, name, log_conf, python_path):
2876 """

Callers 1

RemoveProjectMethod · 0.95

Calls 8

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

Tested by

no test coverage detected