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.

3 Answers 3

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.

2
  • 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?
    – nitin
    Jan 15, 2013 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 4, 2020 at 6: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
2
  • Of course you can use this command in any ftp client.
    – adam111p
    Apr 6, 2015 at 8: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. Apr 6, 2015 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .