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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.