Tag Archives: Gzip file older

Gzip the file older than number of days in Linux

Gzip the file older than number of days in Linux

Gzip is the utility provided by Operating system linux, unix for gzip the files and reduce the size of the files with compression method or algorithms.

You can use find command with combination of gzip command to compressed the files older than 1o days by providing parameter mtime with find command. The following command uses find and gzip command.
 
You can scheduled this command in crontab if you need this activity in regular basis.
 
The following command find the file present at /var/tmp/ having name with .ddg extension and gzip the files older than 10 days.

/usr/bin/find /var/tmp/*.dbg -mtime +10 -exec gzip {} \;

Note: Used the parameter mtime for specify the older no of days.

Advertisements