From 28ea160004c4df8d59ed387720df916d37f38e6c Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 19 Jun 2022 14:32:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=8B=E5=8A=A8=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E4=BB=BB=E5=8A=A1=E8=80=97=E6=97=B6=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/cron.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/back/services/cron.ts b/back/services/cron.ts index 2a0f23fe..0c78b237 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -198,11 +198,21 @@ export default class CronService { const err = await this.killTask(doc.command); const absolutePath = path.resolve(config.logPath, `${doc.log_path}`); const logFileExist = doc.log_path && (await fileExist(absolutePath)); + + const endTime = dayjs(); + const diffTimeStr = doc.last_execution_time + ? `,耗时 ${endTime.diff( + dayjs(doc.last_execution_time * 1000), + 'second', + )}` + : ''; if (logFileExist) { const str = err ? `\n${err}` : ''; fs.appendFileSync( `${absolutePath}`, - `${str}\n## 执行结束... ${dayjs().format('YYYY-MM-DD HH:mm:ss')} `, + `${str}\n## 执行结束... ${endTime.format( + 'YYYY-MM-DD HH:mm:ss', + )}${diffTimeStr}`, ); } }