About Linux timestamps maybe
Posted 01-17-2024 at 02:57 PM by maybeJosiah
Updated 01-31-2024 at 03:42 PM by maybeJosiah (format times maybe)
Updated 01-31-2024 at 03:42 PM by maybeJosiah (format times maybe)
Tags linux, time, timestamps
All Linux has changed time AKA ctime, access time AKA atime, and modified time AKA mtime. Some Linux also has created time/birth time AKA crtime. Like universally all these may be accessed via "stat" with Bash. You may read "stat --help" in your terminal for more specific information. Changed time is last time metadata changed, and others are self explanatory. On some distros "crtime" may be replaced by "btime" and/or "ctime" may be replaved by "chgtime". There may also be with a "st_" prefix so check "sif -l" in debugfs if using debugfs.
To set timestamps on Linux, commonly there is "touch" but that is only for mtime and atime. On ext2 to ext4 there is debugfs. Only use that on unmounted file systems. Two things to set in that, time field as with time names above abbreviated like mtime and that with _extra at end of it. Regular part is date as either hexadecimal seconds since epoch with "@0x" before it or YYYYMMDDHHmmSS +%Y%m%d%H%M%S year month day hour minute second, with that being in UTC time zone, to second precision and that _extra is nanoseconds times 4 of your timestamps. rsync also has all timestamps setting upon copy supported on many distros. Read "rsync --help" or "man rsync" from in a terminal for more info. I find with debugfs, order to set in is crtime, atime, mtime, ctime. In debugfs there may also be like those times and extras with prefix "i_". I recommend setting all you can when you should and with "i_" should be like without.
Another interesting thing I know is that some systems store different numbers of bits for timestamps. If you have 32 bit timestamps please upgrade before 2038. Otherwise you may have 34 bit on ext4 or 64 bit timestamps. A good way to check for size of timestamps is if your nanos has 9 digits means 64 bit, 6 digits, 32 bit. Obviously 32 bit machines are more likely to have 32 bit timestamps and 64 bit machines are likely to have 64 bit timestamps and which of 32 bit or 64 bit distro is also a major factor like machine.
Thank you Petri Kaukasoina, on forum, and Theodore Ts'o, maker of debugfs, for info about debugfs. X E.
To set timestamps on Linux, commonly there is "touch" but that is only for mtime and atime. On ext2 to ext4 there is debugfs. Only use that on unmounted file systems. Two things to set in that, time field as with time names above abbreviated like mtime and that with _extra at end of it. Regular part is date as either hexadecimal seconds since epoch with "@0x" before it or YYYYMMDDHHmmSS +%Y%m%d%H%M%S year month day hour minute second, with that being in UTC time zone, to second precision and that _extra is nanoseconds times 4 of your timestamps. rsync also has all timestamps setting upon copy supported on many distros. Read "rsync --help" or "man rsync" from in a terminal for more info. I find with debugfs, order to set in is crtime, atime, mtime, ctime. In debugfs there may also be like those times and extras with prefix "i_". I recommend setting all you can when you should and with "i_" should be like without.
Another interesting thing I know is that some systems store different numbers of bits for timestamps. If you have 32 bit timestamps please upgrade before 2038. Otherwise you may have 34 bit on ext4 or 64 bit timestamps. A good way to check for size of timestamps is if your nanos has 9 digits means 64 bit, 6 digits, 32 bit. Obviously 32 bit machines are more likely to have 32 bit timestamps and 64 bit machines are likely to have 64 bit timestamps and which of 32 bit or 64 bit distro is also a major factor like machine.
Thank you Petri Kaukasoina, on forum, and Theodore Ts'o, maker of debugfs, for info about debugfs. X E.
Total Comments 0