diff --git a/back/services/cron.ts b/back/services/cron.ts index 10b96ed6..2c67de42 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -74,7 +74,7 @@ export default class CronService { let logFile = `${config.manualLogPath}${res._id}.log`; fs.writeFileSync(logFile, `${new Date().toString()}\n\n`); - const cmd = spawn(res.command, { shell: true }); + const cmd = spawn(`${res.command} now`, { shell: true }); this.cronDb.update({ _id }, { $set: { status: CrontabStatus.running } }); diff --git a/shell/api.sh b/shell/api.sh index 7be48f48..556ed372 100755 --- a/shell/api.sh +++ b/shell/api.sh @@ -26,14 +26,14 @@ add_cron_api() { if [ $# -eq 1 ]; then local schedule=$(echo "$1" | awk -F ":" '{print $1}') local command=$(echo "$1" | awk -F ":" '{print $2}') - local name=$(echo "$1" | awk -F ": " '{print $3}') + local name=$(echo "$1" | awk -F ":" '{print $3}') else local schedule=$1 local command=$2 local name=$3 fi - local api=$(curl "http://localhost:5678/api/crons?t=$currentTimeStamp" \ + local api=$(curl "http://localhost:5600/api/crons?t=$currentTimeStamp" \ -H "Accept: application/json" \ -H "Authorization: Bearer $token" \ -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" \ @@ -55,7 +55,7 @@ add_cron_api() { del_cron_api() { local id=$1 local currentTimeStamp=$(date +%s) - local api=$(curl "http://localhost:5678/api/crons/$id?t=$currentTimeStamp" \ + local api=$(curl "http://localhost:5600/api/crons/$id?t=$currentTimeStamp" \ -X 'DELETE' \ -H "Accept: application/json" \ -H "Authorization: Bearer $token" \ diff --git a/shell/git_pull.sh b/shell/git_pull.sh index 8de49dbf..014673aa 100755 --- a/shell/git_pull.sh +++ b/shell/git_pull.sh @@ -233,12 +233,10 @@ Add_Cron() { echo -e "开始尝试自动添加定时任务\n" JsAdd=$(cat $ListJsAdd) for Cron in $JsAdd; do - local id=$(echo "$1" | awk -F ":" '{print $1}') - local name=$(echo "$1" | awk -F ":" '{print $2}') - if [[ $name == jd_bean_sign ]]; then - echo "4 0,9 * * * $ShellJs $name" >>$ListCronCurrent + if [[ $Cron == jd_bean_sign ]]; then + echo "4 0,9 * * * $ShellJs $Cron" >>$ListCronCurrent else - param=$(cat $ListCronRemote | grep -E "\/$name\." | perl -pe "s|(^.+)node */scripts/(j[drx]_\w+)\.js.+|\1\:$ShellJs \2:\2|") + param=$(cat $ListCronRemote | grep -E "\/$Cron\." | perl -pe "s|(^.+)node */scripts/(j[drx]_\w+)\.js.+|\1\:$ShellJs \2:\2|") add_cron_api "$param" fi done