Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Solution to the problem of inconsistency between crontab execution time and system time

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Preface

In LINUX, periodic tasks are usually 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", which is short for "cron table".

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

Service crond start / / start the service

Service crond stop / / shut down the service

Service crond restart / / restart the service

Service crond reload / / reload configuration

Service crond status / / View service status

Find a problem

The thing is, there is a crontab on your own service as follows.

100 * root echo 'xxx' > > zzz

Everyone familiar with it knows that it will be executed at 00:10 in the evening to output xxx to the zzz file.

But here's the problem. This crontab doesn't execute at 00:10! It was executed at 12:10 noon.

The crontab execution time is inconsistent with the system time!

I remember that the server changed the time zone and now it is the CST time zone. There is no reason not to execute it.

Try crontab time zone under google, and find several similar examples.

Crontab must be restarted manually after the original time has been modified.

/ etc/init.d/crond restart

It is useless to restart crontab and restart the server. It is useless for me to restart the server after changing the time zone. I must restart crontab!

There are also two time zones, one is timezone and the other is localtime, which can be solved by following the command below.

Cp / usr/share/zoneinfo/Asia/Shanghai / etc/localtimeservice crond restart

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report