diff --git a/back/services/cron.ts b/back/services/cron.ts index 95b00dc6..7f0ac69e 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -18,7 +18,7 @@ import { TASK_PREFIX, QL_PREFIX } from '../config/const'; @Service() export default class CronService { - constructor(@Inject('logger') private logger: winston.Logger) {} + constructor(@Inject('logger') private logger: winston.Logger) { } private isSixCron(cron: Crontab) { const { schedule } = cron; @@ -264,9 +264,9 @@ export default class CronService { } } - public async find(params: { log_path: string }): Promise { + public async find({ log_path }: { log_path: string }): Promise { try { - const result = await CrontabModel.findOne({ where: { ...params } }); + const result = await CrontabModel.findOne({ where: { log_path } }); return result; } catch (error) { throw error; diff --git a/shell/rmlog.sh b/shell/rmlog.sh index cc9dae3c..6a311259 100755 --- a/shell/rmlog.sh +++ b/shell/rmlog.sh @@ -19,10 +19,14 @@ remove_js_log() { diff_time=$(($(date +%s) - $(date +%s -d "$log_date"))) fi if [[ $diff_time -gt $((${days} * 86400)) ]]; then - local log_path=$(echo "$log" | sed "s,${dir_log},,g") + local log_path=$(echo "$log" | sed "s,${dir_log}/,,g") local result=$(find_cron_api "log_path=$log_path") - if [[ $result ]]; then + echo -e "查询文件 $log_path" + if [[ -z $result ]]; then + echo -e "删除中~" rm -vf $log + else + echo -e "正在被 $result 使用,跳过~" fi fi fi