How to modify the file's modification time using touch in Linux

Source: Internet
Author: User
Tags exit current time parse string touch touch command

Rsync sometimes because the server time is wrong, you need to change the time of the file modification, you can use the Touch command to modify the file's modified time:

1 touch-c-m-t 201101110000 teadme.txt

Modified Readme.txt to January 11, 2011:00 Modified

If you modify files and directories in bulk, use the

1 find/home/www/site-exec touch-c-m-t 201101110000 {} \;

You can change all the files and directories under the/home/www/site to modify the time.

Note the spaces in the command above.

Touch [-ACDMT] File parameters:

-A: Modify access time only.

-C: Only time is modified, not files are created.

-D: You can follow the date later, or you can use the –date= "date or time"

-M: Modify Mtime only.

-T: can be followed by time, in the form [YYMMDDHHMM]

such as Touch-c-T 0906270730 file

Usage:touch [OPTION] ... FILE ...

Update the access and modification times of all FILE to the current time.

Mandatory arguments to long options are mandatory for short options too.

-A change is the access time

-c,–no-create do don't create any files

-d,–date=string parse STRING and use it instead

-F (ignored)

-M modification Time

-r,–reference=file Use this FILE "s times instead of

-T STAMP use [[CC]YY]MMDDHHMM[.SS] instead of

–time=word Change the specified time:

WORD is access, atime, or Use:equivalent to-a

WORD is modify or mtime:equivalent to-m

–help Display this Help and exit

–version output version information and exit

Note that the-d and-t options accept different time-date formats.

If a FILE is-, touch standard output.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

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.