logrotate irrespective of the size of a file/directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting logrotate irrespective of the size of a file/directory
# 1  
Old 02-07-2011
logrotate irrespective of the size of a file/directory

hi,
How to logrotate irrespective of the size of a file/directory...?
Please help me in this regard...
# 2  
Old 02-07-2011
I hope I'm not the only one that is going to say this but WHAT? Could you give examples of what you are wanting to do? Do you have any code to share that we could help you with? I don't know if it's just me but your request seems convoluted and extremely unclear. Please give examples.
# 3  
Old 02-07-2011
Hi, Please check the below example,
Code:
if [ `grep -c "/var/log/XXX " /etc/logrotate.conf` -eq 0 ] ; then
  echo "/var/log/XXX/*.log "{" >> /etc/logrotate.conf
  echo " rotate 10" >> /etc/logrotate.conf
  echo " size 5M" >> /etc/logrotate.conf
  echo " postrotate" >> /etc/logrotate.conf
  echo " /usr/bin/killall -HUP syslogd" >> /etc/logrotate.conf
  echo " endscript" >> /etc/logrotate.conf
  echo " compress" >> /etc/logrotate.conf
  echo " copytruncate" >> /etc/logrotate.conf
  echo "}" >> /etc/logrotate.conf
fi

But what I required is, as my log file never reaches the max size of 5M and it will be max upto 5-10K(which is also not sure), I would like to logrotate it monthly, irrespective of the size whether it reached some specified size. And also I have to zip all the log files while rotation.

Last edited by Scott; 02-07-2011 at 07:25 AM.. Reason: Code tags, please...
# 4  
Old 02-07-2011
You can do something similar to following,
this is from the logrotate man page:

Code:
 
       # sample logrotate configuration file
       compress
       /var/log/messages {
           rotate 5
           weekly
           postrotate
               /sbin/killall -HUP syslogd
           endscript
       }

# 5  
Old 02-07-2011
What my doubt is, irrespective of the size means, can I ignore using the directive "size" in the code..??
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to search for a string in all the files irrespective of directory.?

Hi All, How to search for a string in all the files irrespective of directory. If I use grep -i 'hello' *.* It will search for the string hello in the files of current directory. But I want to check for the string hello in the files of all the directories. Thanks (4 Replies)
Discussion started by: ROCK_PLSQL
4 Replies

2. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

3. Shell Programming and Scripting

Script to find duplicate pattern in a file irrespective of case

We have a configuration file in Unix. In that we have entries like below. if it ends with ":", then it is the end of record. We need to find our if there is any duplicate entries like ABCD irrespective of the case. ABCD:\ :conn.retry.stwait=00.00.30:\ :sess.pnode.max=255:\ ... (9 Replies)
Discussion started by: johnjs
9 Replies

4. Shell Programming and Scripting

How to delete some of the files in the directory, if the directory size limits the specified size

To find the whole size of a particular directory i use "du -sk /dirname".. but after finding the direcory's size how do i make conditions like if the size of the dir is more than 1 GB i hav to delete some of the files inside the dir (0 Replies)
Discussion started by: shaal89
0 Replies

5. Solaris

Directory size larger than file system size?

Hi, We currently have an Oracle database running and it is creating lots of processes in the /proc directory that are 1000M in size. The size of the /proc directory is now reading 26T. How can this be if the root file system is only 13GB? I have seen this before we an Oracle temp file... (6 Replies)
Discussion started by: sparcman
6 Replies

6. UNIX for Advanced & Expert Users

logrotate with /etc/logrotate.conf file

Hi there, I want to rotate the logfiles which are located in /var/log/jboss/tomcat* so I have created a file named as 'tomat' in /etc/logrotate.d/tomcat with the following content. # cat /etc/logrotate.d/tomcat /var/log/jboss/tomcat_access_log*.log { daily nocreate ... (2 Replies)
Discussion started by: skmdu
2 Replies

7. Ubuntu

logrotate - why ignore size ?

Hi, i have a logroate script that works properly when running manually but otherwise it won't work.I put in in /etc/logrotate.d/nginx. I simply cannot understand why it won't run properly when run with a cronjob. It suppose to run hourly and rotate logs if they are > 3mb. What am i missing here ?:... (1 Reply)
Discussion started by: ktm
1 Replies

8. UNIX for Advanced & Expert Users

logrotate size limit

Hi i configured log rotate for a specific file. /var/log/sauer i configured create a file in logrotate.d # cat /etc/logrotate.d/sauer #this is a logrotate configuration file for msu_ng logs /var/log/sauer { rotate 5 size=1M daily compress ... (5 Replies)
Discussion started by: modcan
5 Replies

9. UNIX for Advanced & Expert Users

Updating entire column irrespective of any data in a file

Hi, I have a file A.txt (tab separated) as below: pavan chennai/tes/bangalore 100 sunil mangalore/abc/mumbai 230 kumar delhi/nba/andhra 310 I want to change only second column as below . Rest of columns as it is ;The ouput file is also tab... (4 Replies)
Discussion started by: kpavan2004
4 Replies

10. UNIX for Dummies Questions & Answers

how to set size in logrotate.conf

Hi,guys: recently,i am puzzled by a question .when i create a new file named by /etc/logrotate.d/debug. The cont. is listed as follow: /var/log/debug { rotate 3 missingok notifempty size=2k prerotate /bin/kill -HUP `cat... (0 Replies)
Discussion started by: icehero
0 Replies
Login or Register to Ask a Question