此脚本将告诉您何时发生时间漂移以及进程树中的差异,如果这是由更改系统时间的进程引起的,则应该有助于识别此情况.它将打印到终端并登录到当前工作目录中的timedrift.log.

#!/bin/bash

oldTime="$(date +%s)"

oldPsOutput="$(ps faux)"

while true; do

sleep 1;

currentTime="$(date +%s)"

oldTimeplusfive="$((($oldTime+5)))"

currentPsOutput="$(ps faux)"

if [[ "$currentTime" -lt "$oldTime" || "$currentTime" -gt "$oldTimeplusfive" ]]

then

(

echo -e '\n\n======================='

echo "currentTime=$currentTime oldTime=$oldTime oldTimeplusfive=$oldTimeplusfive"

echo '-----------------------'

echo "$oldPsOutput"

echo '::::::::::::::::::::::::::'

echo "$currentPsOutput"

) | tee -a timedrift.log

fi

oldPsOutput=$currentPsOutput

oldTime=$currentTime

done

感谢原始剧本在不可知的时间内跳过了作为评论提到的CRON提出的CRON bug.

您是否也可以评论,就好像您正在使用rsyslog,如果是,那么什么版本?你是否在rsyslog领域之外看到它(即apache日志等).这个bug看起来很简单,很高兴确认它或以任何方式排除它.

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐