更新手动执行cron参数

This commit is contained in:
whyour 2021-04-03 22:19:02 +08:00
parent 7eba87aa2c
commit df1dc4fcbb
3 changed files with 7 additions and 9 deletions

View File

@ -74,7 +74,7 @@ export default class CronService {
let logFile = `${config.manualLogPath}${res._id}.log`; let logFile = `${config.manualLogPath}${res._id}.log`;
fs.writeFileSync(logFile, `${new Date().toString()}\n\n`); 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 } }); this.cronDb.update({ _id }, { $set: { status: CrontabStatus.running } });

View File

@ -33,7 +33,7 @@ add_cron_api() {
local name=$3 local name=$3
fi 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 "Accept: application/json" \
-H "Authorization: Bearer $token" \ -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" \ -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() { del_cron_api() {
local id=$1 local id=$1
local currentTimeStamp=$(date +%s) 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' \ -X 'DELETE' \
-H "Accept: application/json" \ -H "Accept: application/json" \
-H "Authorization: Bearer $token" \ -H "Authorization: Bearer $token" \

View File

@ -233,12 +233,10 @@ Add_Cron() {
echo -e "开始尝试自动添加定时任务\n" echo -e "开始尝试自动添加定时任务\n"
JsAdd=$(cat $ListJsAdd) JsAdd=$(cat $ListJsAdd)
for Cron in $JsAdd; do for Cron in $JsAdd; do
local id=$(echo "$1" | awk -F ":" '{print $1}') if [[ $Cron == jd_bean_sign ]]; then
local name=$(echo "$1" | awk -F ":" '{print $2}') echo "4 0,9 * * * $ShellJs $Cron" >>$ListCronCurrent
if [[ $name == jd_bean_sign ]]; then
echo "4 0,9 * * * $ShellJs $name" >>$ListCronCurrent
else 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" add_cron_api "$param"
fi fi
done done