Tuesday, February 10, 2015

Compress a big file

1. Check the filesystem on the system which is over 85% used.
# df -hP  /www/domain/TheDesk/logs/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/datavg-WWW_DOMAIN 30G   24G  4.1G  86% /www/domain
2. Go to the directory location to find a large file.
# cd /www/domain/TheDesk/logs
# du -sh *
# ls -lh app_mod_jk.log.log
-rw-r--r-- 1 root root 21G Feb 10 11:15 app_mod_jk.log.log
3. Since you don't have space on the system, and you simply can't delete the file.
Find another filesystem where you can store the log temporarily.
# df -hP
/dev/mapper/datavg-WWW_APPROOT 30G  1.3G   27G   5% /www/approot
4. Compress your log to different filesystem.
# gzip -c app_mod_jk.log.log > /www/approot/app_mod_jk.log.log.2102015.gz
# ls -lh app_mod_jk.log.log
-rw-r--r-- 1 root root 21G Feb 10 11:27 app_mod_jk.log.log
5. Zero you log.
Note, if size does not change, you may have to hup the process id.
# cat /dev/null >app_mod_jk.log.log
6. Move your compress log back to the original position.
# mv /www/approot/app_mod_jk.log.log.2102015.gz /www/domain/TheDesk/logs/

No comments:

Post a Comment