Sponsored Content
Full Discussion: compress the log files
Top Forums UNIX for Advanced & Expert Users compress the log files Post 302360490 by skmdu on Friday 9th of October 2009 06:15:21 AM
Old 10-09-2009
Code:
Before logrotate


-rw-r--r-- 1 root    root          0 Oct  9 02:46 tomcat_access_log.2009-10-01.log
-rw-r--r-- 1 root    root          0 Oct  9 02:46 tomcat_access_log.2009-09-30.log
-rw-r--r-- 1 root    root          0 Oct  9 02:46 tomcat_access_log.2009-09-29.log
-rw-r--r-- 1 root    root          0 Oct  9 02:46 tomcat_access_log.2009-09-28.log
-rw-r--r-- 1 root    root          0 Oct  9 02:46 tomcat_access_log.2009-09-27.log
-rw-r--r-- 1 root    root          0 Oct  9 02:46 tomcat_access_log.2009-09-26.log
-rw-r--r-- 1 root    root          0 Oct  9 02:46 tomcat_access_log.2009-09-25.log
-rw-r--r-- 1 root    root          0 Oct  9 02:46 tomcat_access_log.2009-09-24.log
-rw-r--r-- 1 root    root          0 Oct  9 02:46 tomcat_access_log.2009-09-23.log


content of /etc/logrotate.conf

/var/log/appn/*.log {
 daily
 compress
 rotate 5
}

After logrotate

-rw-r--r-- 1 root    root         20 Oct  9 02:54 tomcat_access_log.2009-10-01.log.1.gz
-rw-r--r-- 1 root    root          0 Oct  9 02:54 tomcat_access_log.2009-10-01.log
-rw-r--r-- 1 root    root         20 Oct  9 02:54 tomcat_access_log.2009-09-30.log.1.gz
-rw-r--r-- 1 root    root          0 Oct  9 02:54 tomcat_access_log.2009-09-30.log
-rw-r--r-- 1 root    root         20 Oct  9 02:54 tomcat_access_log.2009-09-29.log.1.gz
-rw-r--r-- 1 root    root          0 Oct  9 02:54 tomcat_access_log.2009-09-29.log
-rw-r--r-- 1 root    root         20 Oct  9 02:54 tomcat_access_log.2009-09-28.log.1.gz
-rw-r--r-- 1 root    root          0 Oct  9 02:54 tomcat_access_log.2009-09-28.log
-rw-r--r-- 1 root    root         20 Oct  9 02:54 tomcat_access_log.2009-09-27.log.1.gz
-rw-r--r-- 1 root    root          0 Oct  9 02:54 tomcat_access_log.2009-09-27.log
-rw-r--r-- 1 root    root         20 Oct  9 02:54 tomcat_access_log.2009-09-26.log.1.gz
-rw-r--r-- 1 root    root          0 Oct  9 02:54 tomcat_access_log.2009-09-26.log
-rw-r--r-- 1 root    root         20 Oct  9 02:54 tomcat_access_log.2009-09-25.log.1.gz
-rw-r--r-- 1 root    root          0 Oct  9 02:54 tomcat_access_log.2009-09-25.log
-rw-r--r-- 1 root    root         20 Oct  9 02:54 tomcat_access_log.2009-09-24.log.1.gz
-rw-r--r-- 1 root    root          0 Oct  9 02:54 tomcat_access_log.2009-09-24.log
-rw-r--r-- 1 root    root         20 Oct  9 02:54 tomcat_access_log.2009-09-23.log.1.gz
-rw-r--r-- 1 root    root          0 Oct  9 02:54 tomcat_access_log.2009-09-23.log

Its compressing all the log files and its not removing log files. Any input on this?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to Compress log files?

Hi, I have my log files in /home/user1/temp2/logs i want to archive *.log and *.txt files and to store in my /home/user1/temp2/archved/ with *.log with Time stamp ,Please let me know how to do this? (1 Reply)
Discussion started by: redlotus72
1 Replies

2. Shell Programming and Scripting

Compress multiple files

Hi Friends, Can anyone help me out with compressing multiple files. I have multiple files in directory , I have to compress these into a single file, I tried using gzip -r outfile.gz file1 file2 file3. It is not working Thanks in advance for your help S :) (5 Replies)
Discussion started by: sbasetty
5 Replies

3. UNIX for Dummies Questions & Answers

Compress files

Hi All, I would like to archive some of the scripts below(USFINUM042006_01.CSV USFINUM042006_02.CSV and USFINUM042006_03.CSV )and also use a wildcard e.g. <command> USFINUM*.CSV. Also there are a lot of similar files but I want only the three latest files to be compressed. Which is the best... (3 Replies)
Discussion started by: indira
3 Replies

4. Filesystems, Disks and Memory

Compress files on NAS

Hello, I am having difficulty compressing the files using compress or GZIP utility on NAS share NFS mounted on my linux server. Any one have idea on how to do this ? I get the followign error but the trying to compress the files STRP2> compress STR_OUTBOUND_CDM_LOG_LOB.PRT2008_26.txt... (0 Replies)
Discussion started by: kamathg
0 Replies

5. Shell Programming and Scripting

compress files

Could someone give me an idea how to compress all files from a given directory that are not of type .z (compressed). Please help. (2 Replies)
Discussion started by: lesstjm
2 Replies

6. UNIX for Dummies Questions & Answers

find new files and compress them

Hi! First off I'd like to stress that I'm a true dummy :) I have a website with SSH access and since it has user generated content I want to backup my website every day end send it through FTP to a different server. I got it working for my mysql database, so the only thing remaining are the... (2 Replies)
Discussion started by: Mark Wegener
2 Replies

7. Linux

Compress files >2GB

Hi folks, I'm trying to compress a certain number of files from a cifs mount to a xfs mount, but cannot do it when the total size of the files is bigger than 2GB. Is there any limitation for above 2GB? OS is SLES 64bit The files are maximum 1MB, so there are aprox. 2000 files to compress... (2 Replies)
Discussion started by: xavix
2 Replies

8. UNIX for Dummies Questions & Answers

How to compress files without extension

Could someone please help? I'm trying to compress all the files in a directory without extension. I know for typical files with extension, the command is something like: tar -zcvf file.tar.gz *.doc What is the command for files without extension? Thanks. (4 Replies)
Discussion started by: AChan1118
4 Replies

9. UNIX for Dummies Questions & Answers

Issue: Compress in unix server and FTP to windows and open the compress file using Winzip

Hi All ! We have to compress a big data file in unix server and transfer it to windows and uncompress it using winzip in windows. I have used the utility ZIP like the below. zip -e <newfilename> df2_test_extract.dat but when I compress files greater than 4 gb using zip utility, it... (4 Replies)
Discussion started by: sakthifire
4 Replies

10. UNIX for Dummies Questions & Answers

How do I compress all files in a directory?

the problem states "Write a script that compresses all the files in the directory. Make a directory and put some files in it. Also make a sub directory in your directory and put files in it also. Once you have this basic ability to compress all files within a directory, add to your script a menu of... (1 Reply)
Discussion started by: Brittany
1 Replies
SAVELOG(8)						      System Manager's Manual							SAVELOG(8)

NAME
savelog - save a log file SYNOPSIS
savelog [-m mode] [-u user] [-g group] [-t] [-p] [-c cycle] [-l] [-j] [-J] [-1 .. -9] [-C] [-d] [-l] [-r rolldir] [-n] [-q] [-D dateformat] file ... DESCRIPTION
The savelog command saves and optionally compresses old copies of files. Older versions of file are named: file.<number><compress_suffix> where <number> is the version number, 0 being the newest. Version numbers > 0 are compressed unless -l prevents it. Version number 0 is not compressed because a process might still have file opened for I/O. Only cycle versions of the file are kept. If the file does not exist and -t was given, it will be created. For files that do exist and have lengths greater than zero, the following actions are performed: 1) Version numbered files are cycled. Version file.2 is moved to version file.3, version file.1 is moved to version file.2, and so on. Finally version file.0 is moved to version file.1, and version file is deleted. Both compressed names and uncompressed names are cycled, regardless of -l. Missing version files are ignored. 2) The new file.1 is compressed unless the -l flag was given. It is changed subject to the -m, -u, and -g flags. 3) The main file is moved to file.0. 4) If the -m, -u, -g, -t, or -p flags are given, then an empty file is created subject to the given flags. With the -p flag, the file is created with the same owner, group, and permissions as before. 5) The new file.0 is changed subject to the -m, -u, and -g flags. OPTIONS
-m mode chmod the log files to mode, implies -t -u user chown log files to user, implies -t -g group chgrp log files to group, implies -t -c cycle Save cycle versions of the logfile (default: 7). The cycle count must be at least 2. -t touch new logfile into existence -l don't compress any log files (default: do compress) -p preserve owner, group, and permissions of logfile -j compress with bzip2 instead of gzip -J compress with xz instead of gzip For xz no strength option is set, and xz decides on the default based on the total amount of physical RAM. Note that xz can use a very large amount of memory for the higher compression levels. -1 .. -9 compression strength or memory usage (default: 9, except for xz) -C force cleanup of cycled logfiles -d use standard date for rolling -D dateformat override date format, in the syntax understood by the date(1) command -r use rolldir instead of . to roll files -n do not rotate empty files -q be quiet BUGS
If a process is still writing to file.0, and savelog moves it to file.1 and compresses it, data could be lost. SEE ALSO
logrotate(8) Debian 30 Dec 2017 SAVELOG(8)
All times are GMT -4. The time now is 04:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy