diff --git a/back/services/cron.ts b/back/services/cron.ts index d9ac9003..f0f090cb 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -186,7 +186,10 @@ export default class CronService { cmd.on('exit', (code: number, signal: any) => { this.logger.silly(`cmd exit ${code}`); - this.cronDb.update({ _id }, { $set: { status: CrontabStatus.idle } }); + this.cronDb.update( + { _id }, + { $set: { status: CrontabStatus.idle }, $unset: { pid: true } }, + ); fs.appendFileSync(logFile, `\n\n执行结束...`); }); diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx index 693d1e5a..0d9288d1 100644 --- a/src/pages/crontab/index.tsx +++ b/src/pages/crontab/index.tsx @@ -99,12 +99,12 @@ const Crontab = () => { align: 'center' as const, render: (text: string, record: any) => ( <> - {record.status === CrontabStatus.idle && ( + {record.status !== CrontabStatus.disabled && !record.pid && ( } color="default"> 空闲中 )} - {record.status === CrontabStatus.running && ( + {record.status === CrontabStatus.running && record.pid && ( } color="processing"> 运行中