Linux Command date

Source: Internet
Author: User

Linux Command date

Date

1. query system time

2.-d is followed by characters to query the time of a specific condition, such as 3 days ago, 2 days later, 5 minutes later, 6 seconds ago, 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 before 05:05:05 a year later

3.-s: set the system time

Date-s 12/31/2015 set year month day

Date-s 22:05:20 set the time

You need to set it in two steps. You do not know how to set it once.

Another problem is to change the default time display format of the system. This is unknown and may be related to the locale command.

4. + % Y % m % d set the display format

% Y 1999 full year

% Y 99-year ending count

% M December

% D 31 days

% H 24 hour

% I 12 12 hour

% M 60 points

% S 60 seconds

% W weeks 0-7

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

% F % Y-% m-% d

% T % H: % M: % S

[Root @ wjf ~] # Date + % Y _ % m _ % d ___ % H: % M: % s2014_12_021__00: 26: 05
5. -r is followed by a file name, which can display the last modification time of the file. It is very useful. You can use this method to extract the modification time of the file to delete the file in a specific time period in shell.
[Root @ wjf ~] # Date-r db2exp. rsp Monday 1, November 24, 2014 18:13:57 CST [root @ wjf ~] # Ll db2exp. rsp-rw-r -- 1 root 1667 11-24 18:13 db2exp. rsp

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.