crontab execution time inconsistent with system time resolved

  • 2020-12-20 03:57:21
  • OfStack

preface

In LINUX, tasks performed periodically are typically handled by the cron daemon [ps-ef |grep cron]. cron reads one or more configuration files that contain the command line and its call time.

The configuration file for cron is called "crontab", short for "cron table".

cron is a timed execution tool under linux that can run jobs without human intervention.

[

service crond start // Start service
service crond stop // Turn off service
service crond restart // Restart the service
service crond reload // Reload configuration
service crond status // View service status

]

Found the problem

The thing is that on your own service there is 1 crontab as follows


10 0 * * * root echo 'xxx' >> zzz

Those of you who are familiar with it know that it's done at 00:10 PM and output xxx to the zzz file

But here comes the problem. This crontab is not executed at 00:10! It's executed at 12:10 p.m.

crontab execution time and system time are not 1!!!!

I remember that the server changed the obsolete zone which is now also the CST time zone and there is no reason not to implement it!

Try google, crontab time zone, and I did find a few similar examples

crontab had to be restarted manually after the original time change


/etc/init.d/crond restart
[

It is no use having to restart the crontab server, it is no use having to restart the server after I changed the time zone, crontab must be restarted!

]

In another case, distinguish between the two, one is timezone and the other is localtime. Follow the following command to solve the problem


cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
service crond restart

conclusion


Related articles: