How to change the file timestamp in Unix

How to change the file timestamp in Unix

There could be a situation where we need to change the timestamp of the file to simulate a certain scenario (for example Dynamic Storage Tiering based on the file creation time).  We can achieve this by using touch command 

First create a dummy file
# touch xx

# ls -al | grep xx
-rw-r–r–  1 root root         0 Jul 29 16:50 xx

It is created on 29th 2010. I want to make it two year old (let’s say 2008-01-01).  We can change that by using following command

# touch -t 200801012359 xx

Let’s verify the timestamp of the changed file.

# ls -al | grep xx
-rw-r–r–  1 root root         0 Jan  1  2008 xx

Advertisements
This entry was posted in Unix OS and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s