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

How to modify system time by linux

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

Share

Shulou(Shulou.com)05/31 Report--

This article is about how linux modifies system time. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The command of linux to modify the system time is "date". The function of the date command is to display or set the date and time of the system. The format is set to a plus sign followed by several marks, different marks show different time formats, and the syntax is "date'+ time stamp".

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

The Linux date command can be used to display or set the date and time of the system. In terms of display, users can set the format they want to display. The format is set to a plus sign followed by several tags. The list of available tags is as follows:

In terms of time:

%: print%

% n: next line

% t: tabbed

% H: hours (00.23)

% I: hours (01.. 12)

% k: hour (0.23)

% l: hour (1.. 12)

% M: minutes (00.59)

% p: show local AM or PM

% r: direct display time (12-hour format in hh:mm:ss [AP] M)

% s: seconds since 00:00:00 UTC on January 1, 1970

% S: seconds (00.61)

% T: direct display time (24-hour system)

% X: equivalent to% H:%M:%S

% Z: show time zone

In terms of date:

% a: what day of the week (Sun..Sat)

% A: what day of the week (Sunday..Saturday)

% b: month (Jan..Dec)

% B: month (January..December)

% c: display date and time directly

% d: day (01.31)

% D: direct display date (mm/dd/yy)

% h: same as% b

% j: day of the year (001. 366)

% m: month (01.. 12)

% U: week ordinal of the year (00.53) (with Sunday as the first day of the week)

% w: day of the week (0.6)

% W: week ordinal of the year (00.53) (with Monday as the first day of the week)

% x: direct display date (mm/dd/yy)

% y: last two digits of the year (00.99)

% Y: full year (000.9999)

If you do not start with a plus sign, you want to set the time, and the time format is MMDDhhmm [[CC] YY] [.ss], where MM is the month, DD is the day, hh is the hour, mm is the minute, CC is the first two digits of the year, YY is the last two digits of the year, and ss is the number of seconds.

Permissions: all users.

When you do not want to have meaningless zeros (such as 1999-03-07), you can insert a-symbol into the tag, such as date'+%-HGV% Muhamma% Mui S', which will remove the meaningless zeros in hours and seconds, such as the original 08:09:04 will become 8:9:4. In addition, only those who have obtained the rights (such as root) can set the system time.

When you change the system time as root, remember to write the system time to CMOS with clock-w, so that the system time will continue to maintain the latest correct value the next time you reboot.

The syntax is:

Date [- u] [- d datestr] [- s datestr] [--utc] [--universal] [--date=datestr] [--set=datestr] [--help] [--version] [+ FORMAT] [MMDDhhmm [[CC] YY] [.ss]]

Where:

-d datestr: displays the time set in datestr (non-system time)

-- help: displays auxiliary messages

-s datestr: sets the system time to the time set in datestr

-u: displays the current Greenwich mean time

-- version: displays the version number

Thank you for reading! This is the end of this article on "how to modify the system time of linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

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