4

Some of the files we receive on our Redhat server are showing date different from upload date as the last modification time. For us the modification time is important as we classify files depending on date we receive it. Some of these file show earlier timestamps, maybe that of files original creation/modification date on client machine.

nitins
  • 2,579
  • 15
  • 44
  • 68

3 Answers3

2

*nix filesystems provide 3 distinct timestamps:

  • mtime is the time the file's contents was last modified
  • ctime is the time the file's attributes were last changed
  • atime is the time the file was last accessed

The timestamp usually shown in directory listings is the mtime, because it is the most useful; however, many FTP servers will upload a file to a temporary filename and then rename the file once complete, to avoid exposing incomplete files to the OS.

This causes the mtime and ctime to differ for newly-created (uploaded) files; the ctime will show the time the file finished uploading and was renamed, while the mtime will show file creation time.

If you can show some samples of what you're talking about, perhaps additional help can be offered.

adaptr
  • 16,576
  • 23
  • 34
  • Thanks for your explanation. I was able to list all the files that came yesterday using -ctime -1 flag for find which I wasn't with with -mtime flag. So ctime will always show the upload time-stamp, right? – nitins Jan 15 '13 at 11:21
  • It's worth mentioning that one of the `ctime`'s _attributes_ are file data blocks. So when you modify the content of a file both `mtime` and `ctime` get updated. – Yuri Jun 04 '20 at 06:26
0

When I want to change the file modification time, I use an FTP client on the console. Log on with ftp ftp.example.com, then

  • cd commands go to the correct directory
  • SITE command to move the extended command mode
  • UTIME somefile.txt 20050101123000 20050101123000 20050101123000 UTC

Change the access time, modification time, it's time to create a directory on 2005-01-01 12:30:00 somefile.txt. Complete example:

site UTIME somefile.txt 20150331122000 20150331122000 20150331122000 UTC
Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
adam111p
  • 101
  • Of course you can use this command in any ftp client. – adam111p Apr 06 '15 at 08:58
  • 1
    This does not answer the question: you can manually modify dates with this, but it doesn't help with the problem where file loses information on real modification dates during upload. – Esa Jokinen Apr 06 '15 at 10:29
0

This link can help

https://superuser.com/questions/234158/show-both-ctime-and-atime-in-ls-output

stat -c '%x %z' filename.txt

as answered weeheavy