2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 12:40:25 +08:00

fix: cron添加脚本不保存

This commit is contained in:
耗子
2024-10-21 01:07:37 +08:00
parent f182eab2dc
commit 354705ec5b

View File

@@ -92,6 +92,9 @@ panel-cli cutoff website -n %s -p %s
panel-cli cutoff clear -t website -f %s -s %d -p %s
`, req.Target, req.BackupPath, req.Target, req.Save, req.BackupPath)
}
if req.Type == "shell" {
script = req.Script
}
shellDir := fmt.Sprintf("%s/server/cron/", app.Root)
shellLogDir := fmt.Sprintf("%s/server/cron/logs/", app.Root)
@@ -200,24 +203,6 @@ func (r *cronRepo) Status(id uint, status bool) error {
return app.Orm.Save(cron).Error
}
func (r *cronRepo) Log(id uint) (string, error) {
cron, err := r.Get(id)
if err != nil {
return "", err
}
if !io.Exists(cron.Log) {
return "", errors.New("日志文件不存在")
}
log, err := shell.Execf("tail -n 1000 '%s'", cron.Log)
if err != nil {
return "", err
}
return log, nil
}
// addToSystem 添加到系统
func (r *cronRepo) addToSystem(cron *biz.Cron) error {
if _, err := shell.Execf(`( crontab -l; echo "%s %s >> %s 2>&1" ) | sort - | uniq - | crontab -`, cron.Time, cron.Shell, cron.Log); err != nil {