Also you can use log-rotate for the same, see following example
# Logrotate file for trace
/source/path/trace_*.log {
missingok
create
compress
rotate 1
lastaction
# After compressing logs, move to other location
Log_dir="/target/dir/old_log_$(date +%F)/$(date +%H_%S)/"
[[ ! -d "${Log_dir}" ]] && /bin/mkdir -p "${Log_dir}"
/bin/mv /source/path/*.gz "${Log_dir}"
endscript
}
save above file, let say /etc/logrotate_trace.conf
then simply set cron job for every hour
00 * * * * /usr/sbin/logrotate -f /etc/logrotate_trace.conf
for testing you can run it from command line as
/usr/sbin/logrotate -f /etc/logrotate_trace.conf
The relevant aspects are the kernel versions and these lines from early in the boot process:
kernel: Fast TSC calibration using PIT
...
kernel: Calibrating delay loop (skipped), value calculated using timer frequency..
...
kernel: Switching to clocksource tsc
YMMV and you may not be using TSC or PIT
AFAIK this is a bug that's caused by the clock of at least one of your CPUs being out of sync, in your case probably running too fast.
It should be easy to confirm by running this:
for cpu in {0..8} ; do taskset -c $cpu date ; done
which will run date
against each cpu (assuming you have up to 8 cores/threads). If my guess is correct then one of your CPUs will consistently have the wrong time.
If that's the case then you should first try upgrading the kernel and if that doesn't work, fiddle with the clocksource boot parameter (assuming it's x86-64
):
clocksource= Override the default clocksource
Format: <string>
Override the default clocksource and use the clocksource
with the name specified.
Some clocksource names to choose from, depending on
the platform:
[all] jiffies (this is the base, fallback clocksource)
[ACPI] acpi_pm
...
[X86-64] hpet,tsc
See also the output of this:
cat /sys/devices/system/clocksource/clocksource*/available_clocksource
Best Answer
Could you take a look into your crontab? Maybe something is defined there as a every 5-minute task.