Time zone issues for cron execution time under Debian

Source: Internet
Author: User
Tags london time zone


The default installed time zone for VPS I purchased is Moscow (East quad)? And look at the execution of several commands:

root@blogguy_cn:~# Date
Wed 8 20:16:23 MSK 2014
root@blogguy_cn:~# Date-u
Wed 8 16:16:26 UTC 2014
root@blogguy_cn:~# Date-r
Wed 2014 20:18:39 +0400

See it! Time zone is MSK, 4 hours later than GMT. This is not the main problem that we often encounter. The problem is the following:

I want to perform the following crontab:

0 0 * * * root/var/www/cron_book.sh >>/var/www/crontab_book.log 2 >&1

Guess what time the task will be executed?

My intention is to do it at 12 o'clock midnight, and the result? Check the log:

2014-01-08 04:00:08 Start

It's a little confusing. I tried to change the time to UTC with no effect.

The time zone can only be changed to the UTC unified London time zone/etc/localtime file

Ln-sf/usr/share/zoneinfo/europe/london/etc/localtime

The same show modifies the/etc/timezone file, the original file is:

Etc/utc
Europe/moscow

Modified to:

Etc/utc
Europe/london

And then run:

root@111cn.net:~# Date
Wed 8 16:25:24 GMT 2014
root@111cn.net:~# Date-u
Wed 8 16:25:28 UTC 2014
root@111cn.net:~# Date-r
Wed 2014 16:25:37 +0000

Summary reason:

Within the Linux system, the system time is determined by hardware time, UTC (/ETC/DEFAULT/RCS), timezone three factors. Where the UTC option in/etc/default/rcs tells the Linux system whether this hardware time is UTC, TimeZone is the UTC time zone where the system is set (we are usually set to Asia/shanghai). When the system starts, it reads the hardware time and calculates the system localtime based on the UTC time and the timezone of the system. Debian defaults to the world Time (UTC) as the BIOS time, so the system time is 8 hours faster than it actually is.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.