Solution to the inconsistency between crontab execution time and system time

Solution to the inconsistency between crontab execution time and system time

Preface

In LINUX, periodic tasks are usually handled by the cron daemon process [ps -ef | grep cron]. Cron reads one or more configuration files that contain command lines and the times they are called.

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

Cron is a scheduled 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 the configuration service crond status //Check the service status

Find the problem

The thing is that there is a crontab like the following on your own service

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

Those who are familiar with it know that it is executed at 00:10 at night and outputs xxx to the zzz file

But the problem is that this crontab is not executed at 00:10! Instead, it is executed at 12:10 noon.

The crontab execution time is inconsistent with the system time! ! ! !

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

I tried to google crontab time zone, and I found several similar examples.

It turns out that crontab must be restarted manually after the time is modified

/etc/init.d/crond restart

I have to restart crontab. Restarting the server is useless. I changed the time zone and restarted the server, but it was useless. I have to restart crontab!

There is another situation where the time zone is divided into two, one is timezone and the other is localtime. Follow the following command to solve it

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

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • Use the Linux command crontab to execute other commands at intervals
  • How to use Linux Crontab to execute PHP scripts regularly
  • Linux uses crontab to implement PHP execution plan timing tasks
  • Detailed explanation of using crontab to execute tasks regularly under CentOS 7
  • How to use crontab to execute a scheduled task once a second in Linux
  • How to execute tasks regularly under Linux and instructions on how to use crontab (collected and sorted)
  • Two ways to use crontab to execute a script every few days
  • Solution to crontab not being able to execute php
  • How to implement crontab execution every 10 seconds
  • Linux crontab implements an example of execution per second

<<:  How to use history redirection in React Router

>>:  Solution to forgetting the root password of self-built MySQL in Alibaba Cloud Linux CentOS 7.2

Recommend

Solution to Docker disk space cleaning

Some time ago, I encountered the problem that the...

Linux parted disk partition implementation steps analysis

Compared with fdisk, parted is less used and is m...

CSS3 creates web animation to achieve bouncing ball effect

Basic preparation For this implementation, we nee...

iframe parameters with instructions and examples

<iframe src=”test.jsp” width=”100″ height=”50″...

CSS realizes the realization of background image screen adaptation

When making a homepage such as a login page, you ...

The difference between where and on in MySQL and when to use them

When I was writing join table queries before, I a...

MySQL 5.7.17 installation and configuration graphic tutorial

The blogger said : I have been writing a series o...

SQL group by to remove duplicates and sort by other fields

need: Merge identical items of one field and sort...

HTML Tutorial: Collection of commonly used HTML tags (4)

Related articles: Beginners learn some HTML tags ...

Nginx rewrite regular matching rewriting method example

Nginx's rewrite function supports regular mat...

MySQL 8.0 Window Function Introduction and Summary

Preface Before MySQL 8.0, it was quite painful to...

Detailed explanation of MYSQL large-scale write problem optimization

Abstract: When people talk about MySQL performanc...

Let you understand the working principle of JavaScript

Table of contents Browser kernel JavaScript Engin...