Saturday, August 22, 2015

Compressing file

3.0G    opt
5.6G    var



655M    cache

4.8G    log
1.3G    messages
1.8G    messages.1
1.8G    messages.2

1. Check where you are?
# pwd
/var/log

2. Check the size of the file that you are going to compress
# du -sh *
# du -sh messages.2.gz

3. Compress the file
# gzip messages.2
# gzip messages.1

4. If you don't have space on current FS, redirect the content output to other FS to compress the file,
# gzip -c messages >/var/tmp/messages.11.29.2013.gz

5. Null the file that you just compress
# cat /dev/null>messages

6. Move the compressed file back to the same place where you compress the file.
# mv /var/tmp/messages.11.29.2013.gz .
# ls -ltr
-rw-r--r-- 1 root root      55778475 Nov 29 10:47 messages.11.29.2013.gz
-rw------- 1 root root        122998 Nov 29 10:48 messages



No comments:

Post a Comment