1.3-date command

Source: Internet
Author: User

Date and time of output

Cal View calendar of the month Cal-y view year-round calendar

Modify the system time date-s "2014-12-30 13:23:23"

Network update time Yum install-y NTP

Ntpdate ntp.fudan.edu.cn uses the time server of Fudan University to proofread time.

Date +%f only prints dates such as: 2014-12-30

Date +%t only print time such as: 13:23:23

Date +%y only prints years such as: 2014

Date +%y only prints two-bit years such as: 14 (years)

Date +%m Print month only: 12 (month)

Date +%d only Print day: 30 (day)

Date +%h only print hours such as: 12 (when)

Date +%m only prints minutes such as: 23 (min)

Date +%s only prints seconds such as: 23 (seconds)

Date +%s printing distance 1970-1-1 0:0:0 How many seconds it's been, it's a time stamp.

Date +%w only prints the day of the Week: 1 (Week 1 Note: Sunday: 0)

Date +%w only prints the first weeks such as: 52 (today is the 52nd week of this year)

Date + "%y-%m-%d%h:%m:%s" to customize the format of dates displayed. There are spaces in the middle, so use quotation marks.

Date-d "-2 Days" +%f show 2 day ago date as: 2014-12-18

Date-d "-2 month" +%f Show dates before February

Date-d "-2 Hour" +%t show 2 hours ago When: 11:23:23

Date-d "-2 min" +%t Show time 2 minutes ago

Date-d "-2 SEC" +%t Show time 2 seconds ago

This command is commonly used in scripts, and system-generated log files are named by date.


1.3-date command

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.