2

I use stat to get information of files, I notice

Access: 2013-12-28 13:12:11.244573123 +0100
Modify: 2013-11-12 22:54:42.274460079 +0200
Change: 2013-12-13 12:45:08.164394887 +0100

the +0100 +0200 means "time offset from UTC"

I want to make the second line as:

Modify: 2013-11-12 22:54:42.274460079 +0100

How to modify it?

thanks!

lily
  • 2,015

2 Answers2

1

The stat program is showing local-time for each of the access, modify and change-dates. The odd one is probably in the daylight savings time, shifting it by an hour (though November 12 seems late for this, I see the pattern in results from stat on my Debian 7 machine).

For example, my timezone is normally EST5EDT, and I see this:

$ stat vbx-minix3.2-gcc-normal-run.log
  File: `vbx-minix3.2-gcc-normal-run.log'
  Size: 164806          Blocks: 328        IO Block: 4096   regular file
Device: fe01h/65025d    Inode: 550759      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1001/     tom)   Gid: (  100/   users)
Access: 2015-12-18 21:30:09.081845121 -0500
Modify: 2014-07-25 17:16:10.000000000 -0400
Change: 2015-09-18 19:08:03.501222363 -0400
 Birth: -

By overriding the timezone, I can see the dates all with the same offset:

$ TZ=EST5 stat vbx-minix3.2-gcc-normal-run.log
  File: `vbx-minix3.2-gcc-normal-run.log'
  Size: 164806          Blocks: 328        IO Block: 4096   regular file
Device: fe01h/65025d    Inode: 550759      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1001/     tom)   Gid: (  100/   users)
Access: 2015-12-18 21:30:09.081845121 -0500
Modify: 2014-07-25 16:16:10.000000000 -0500
Change: 2015-09-18 18:08:03.501222363 -0500
 Birth: -

You can probably choose an equivalent TZ which omits the daylight savings time option.

What one sees depends on what their timezone is set to. The offset shown depends solely on (a) the time of the year when the change occurred and (b) the local machine configuration used to display the time.

0

Have you tried changing your TZ export?

[root@pm-prod-email01 ~]# stat /etc/sysconfig/clock
  File: `/etc/sysconfig/clock'
  Size: 27          Blocks: 8          IO Block: 4096   regular file
Device: ca01h/51713d    Inode: 65628       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-12-18 14:08:21.000000000 -0800
Modify: 2013-10-10 10:53:17.000000000 -0700
Change: 2013-10-10 10:53:17.000000000 -0700
[root@pm-prod-email01 ~]# TZ='Asia/Kolkata'
[root@pm-prod-email01 ~]# export TZ
[root@pm-prod-email01 ~]# stat /etc/sysconfig/clock
  File: `/etc/sysconfig/clock'
  Size: 27          Blocks: 8          IO Block: 4096   regular file
Device: ca01h/51713d    Inode: 65628       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-12-19 03:38:21.000000000 +0530
Modify: 2013-10-10 23:23:17.000000000 +0530
Change: 2013-10-10 23:23:17.000000000 +0530
[root@pm-prod-email01 ~]#
jbrahy
  • 131