Date of the Linux command

Source: Internet
Author: User

Date

1. Query the system time

2.-d followed by characters, query for specific conditions of time, such as 3 days ago, 2 days later, 5 minutes later, 6 seconds before etc.

Date-d ' 2 day ago ' two days ago

Date-d ' 3 year ' three years later

Date-d ' 1 Year 3 day ago 5 Hour 5 min 5 sec ' 3 days ago 5:5 5 Seconds later

3.-s Setting the system time

Date-s 12/31/2015 Set Month Day

Date-s 22:05:20 Set time

It needs to be set up in two steps and temporarily unaware of the way it was set.

Another problem is changing the default time display format for the system, which is not known and may be related to the locale command.

4.+%y%m%d Setting the display format

%y 1999 Full Year

%y 99 Mantissa

%m December

%d 31 days

%H 24 24 O'Clock

%I 12 12 O'Clock System

%M 60 min

%s 60 seconds

%w Week 0-7

Combination Method%d%y/%m/%d

%F%y-%m-%d

%T%h:%m:%s

[Email protected] ~]# date +%y_%m_%d___%h:%m:%s2014_12_02___00:26:05
5.-r after the file name, you can display the last modification time of files, is a very useful thing, in the shell to delete a specific time period of the file, you can use this to extract the file modification time.

[[email protected] ~]# date-r DB2EXP.RSP November 24, 2014 Monday 18:13:57 Cst[[email protected] ~]# ll db2exp.rsp-rw-r--r--1 Root root 1667 11-24 18:13 db2exp.rsp




Date of the Linux 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.