Technology Insights

How to Modify the timestamp (Date and Time) of a File on Linux

There are certain circumstances where you may want to modify the date and time of a file on Linux. In my case I was testing a cronjob that moved and deleted files older than a certain date and testing it was much easier after modifying the date of the files.

The command to use for modifying the date and time of a file is called touch. To modify the timestamp of a file issue one of the below commands. The file used in each of the examples below is named testfile.