From 0bf4aec74ef409d87d1396d4e9bcd16162a3c31a Mon Sep 17 00:00:00 2001 From: whyour Date: Sat, 23 Oct 2021 23:22:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpython3=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=81=9C=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/cron.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/back/services/cron.ts b/back/services/cron.ts index ddec21ec..5644a227 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -241,19 +241,19 @@ export default class CronService { } private async killTask(name: string) { - let taskCommond = `ps -ef | grep "${name}" | grep -v grep | awk '{print $1}'`; + let taskCommand = `ps -ef | grep "${name}" | grep -v grep | awk '{print $1}'`; const execAsync = promisify(exec); try { - let pid = (await execAsync(taskCommond)).stdout; + let pid = (await execAsync(taskCommand)).stdout; if (pid) { pid = (await execAsync(`pstree -p ${pid}`)).stdout; } else { return; } - const pids = pid.match(/\d+/g); + const pids = pid.match(/\(\d+/g); const killLogs = []; for (const id of pids) { - const c = `kill -9 ${id}`; + const c = `kill -9 ${id.slice(1)}`; const { stdout, stderr } = await execAsync(c); if (stderr) { killLogs.push(stderr);