I would like to be able to change a file's modification date for use in a web application. For the time being I am testing this directly on the command line. Works fine on my mac, but when I do this on a linux server get error.
Command: /bin/touch -m -t 200906041200 /foo/bar/file.whatever
Error: /bin/touch: setting times of `/foo/bar/file.whatever': Operation not permitted
The file in question is 777.
Changing file timestamps to a specific date and time If you have a specific time and date you would like to be used for all the timestamps of a file or directory, touch command will gladly accempt a timestamp template with -t command line option. Template for the timestamp is quite thorough: [[CC]YY]MMDDhhmm[.
If you ever want to quickly update the Modified time stamp of a file to the current day and time, right-click that file, select Properties, select the TimeStamps tab, and then click the Touch button. That will instantly change the Last modified entry to the current day and time.
On Linux you must be the file owner (or root) to change the modification time to a time other than the current time. There are some other restrictions as well. man utime
for complete details.
Even though the file permissions may be read/write for owner, group and other, I believe you need to actually own the file in order to change the atime for the file in question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With