feat: Add python2 and python3 options to the cronjob interpreter (#10662)

This commit is contained in:
ssongliu 2025-10-16 14:40:41 +08:00 committed by GitHub
parent e2efa20582
commit 72e6b9b188
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -156,9 +156,13 @@ func (u *CronjobService) handleShell(cronjob model.Cronjob, taskItem *task.Task)
cronjob.Executor = "bash"
}
if cronjob.ScriptMode == "input" {
fileItem := pathUtils.Join(global.Dir.DataDir, "task", "shell", cronjob.Name, cronjob.Name+".sh")
suffix := ".sh"
if strings.HasPrefix(cronjob.Executor, "python") {
suffix = ".py"
}
fileItem := pathUtils.Join(global.Dir.DataDir, "task", "shell", cronjob.Name, cronjob.Name+suffix)
_ = os.MkdirAll(pathUtils.Dir(fileItem), os.ModePerm)
shellFile, err := os.OpenFile(fileItem, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, constant.FilePerm)
shellFile, err := os.OpenFile(fileItem, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, constant.DirPerm)
if err != nil {
return err
}

View file

@ -427,8 +427,10 @@
v-model="form.executor"
>
<el-option value="bash" label="bash" />
<el-option value="python" label="python" />
<el-option value="sh" label="sh" />
<el-option value="python" label="python" />
<el-option value="python2" label="python2" />
<el-option value="python3" label="python3" />
</el-select>
<el-input
clearable