How to change file date in linux

Once on one TFTP server, to which my scripts downloaded backups from network equipment, it was necessary to clean up files older than 200 days so that the disk system memory does not overflow, I used the command to clean up:

find /srv/tftp/ -type f -mtime +200 -exec rm {} \;

But since the TFTP server had the necessary phone book file that could not be deleted, it was used by Grandstream IP phones, I just decided to add a command to the script that changes the file modification date to the current one:

touch -mat "`date +%Y%m%d%H%M.%S`" phonebook.xml

Accordingly, the file will not become obsolete and the script will not delete it, check the date of the file:

stat phonebook.xml

See my other Linux articles

Leave a comment

Leave a Reply