Will the scope be there in logrotate after postrotate directive...?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Will the scope be there in logrotate after postrotate directive...?
# 1  
Old 02-14-2011
Will the scope be there in logrotate after postrotate directive...?

Hi,
Please check the below code...Smilie

Code:
 
if [ `grep -c "/var/log/AAA/BBB" /etc/logrotate.conf` -eq 0 ] ; then
        echo "/var/log/AAA/BBB/xxx_*.log  /var/log/AAA/BBB/yyy_*.log  {"  >> /etc/logrotate.conf
        echo "  weekly"                        >> /etc/logrotate.conf
        echo "  rotate 10"                     >> /etc/logrotate.conf
        echo "  compress"                      >> /etc/logrotate.conf
        echo "  postrotate"                    >> /etc/logrotate.conf
        echo "     /usr/bin/killall -HUP syslogd" >> /etc/logrotate.conf
        echo "     sleep 3"                    >> /etc/logrotate.conf
        echo "     mv /var/log/AAA/BBB/xxx_*.gz  /var/log/AAA/BBB/xxx_`date +%d%b%y`.log.gz" >> /etc/logrotate.conf
        echo "     mv /var/log/AAA/BBB/yyy_*.gz  /var/log/AAA/BBB/yyy_`date +%d%b%y`.log.gz" >> /etc/logrotate.conf
        echo "  endscript"                     >> /etc/logrotate.conf
        echo "  copytruncate"                  >> /etc/logrotate.conf
        echo "}"                               >> /etc/logrotate.conf
fi

In this, I am trying to compress and logrotate 2 types of log files in the same folder. Also renaming the files with the current date as a part of them, which denotes the date of rotation. After Postrotate and endscript tags, i am using copytruncate. But in the postrotate tag, I am renaming the file names. So will it effect the copytruncate... or any other directive in the logrotate.conf file...?
Will the previous log files be removed asusual..?
Please help me in this regard...Smilie

Last edited by Dedeepthi; 02-14-2011 at 07:11 AM.. Reason: Typo mistake...
# 2  
Old 02-14-2011
If some processes are still running on the logfile, you should not move them (inode loss) you should use a cp and cat combination instead.
# 3  
Old 02-14-2011
Can you plz help me how to do that...?
Here, my requirement is after renaming the ZIP files, the previous log files should be removed without any problem after the postrotate script.
In the postrotate, will the scope of the logrotate be lost.. bcz as we are using normal shell scripting..?
If scope is lost, how to get it back..?

Last edited by Dedeepthi; 02-14-2011 at 07:39 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell directive not working

$ cat tmp.sh #!/tools/bin/bash echo $BASH_VERSION $ cat tmp.pl #!/usr/local/bin/perl use strict; use warnings; use DBI; use CGI; system("tmp.sh");$ tmp.sh 3.2.48(1)-release The result is as expected. $ tmp.pl 3.2.25(1)-releaseThe result is not as expected. The shell directive in... (5 Replies)
Discussion started by: carloszhang
5 Replies

2. AIX

Logrotate - /etc/logrotate.conf does't exist

Hi Admins. I have installed logrotate rpm on Aix 6.1. After the installation of rpm, I don't find /etc/logrotate.conf file and /etc/logrotate.d dir . The config file is located in /opt/freeware/etc/logrotate.conf. When I ran logrotate -v /opt/freeware/etc/logrotate.conf I get below... (2 Replies)
Discussion started by: snchaudhari2
2 Replies

3. Shell Programming and Scripting

Logrotate - I am not able to rotate files using logrotate

I have written script which is working in Home directory perfectly and also compressing log files and rotating correctly. But, when i try to run script for /var/log/ i am able to get compressed log files but not able to get rotation of compressed log files. Please suggest. I am using below command... (5 Replies)
Discussion started by: VSom007
5 Replies

4. UNIX for Dummies Questions & Answers

Help me with find and tar on postrotate script

Hi, My requirements are I wanted to move my daily logs to /appl/logs/old folder Archive and compress all 10 days older log files under /appl/logs/old in YYYYMMDD format file To remove any 60 days older log files from /appl/logs/old I tried this scenario with logrotate utility ... (1 Reply)
Discussion started by: laxyblack
1 Replies

5. Red Hat

error running postrotate script

Hi, I am getiing emails from cron.daily with subject: Cron root@vsftp run-parts /etc/cron.daily /etc/cron.daily/logrotate: /sbin/killall -HUP radiusd : line 1: /sbin/killall: No such file or directory error: error running postrotate script for /var/log/vsftpd/logfile the... (6 Replies)
Discussion started by: renuka
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. Web Development

regex in apache Allow from directive

Hi, Does the apache Allow from directive support regular expressions? such as: Allow from ^web11blah\.blah\.blah\.yahoo\.com$ what i want to do: allow access from hosts in the range web1160blah.blah.blah.yahoo.com to web1189blah.blah.blah.yahoo.com notice the 1160 to 1189 range as part... (3 Replies)
Discussion started by: Yogesh Sawant
3 Replies

8. Shell Programming and Scripting

vpath directive in make

Hi all, I need to check the contents of my vpath directive in my file. Is it possible to check the contents of the vpath directive as we do for a variable like @echo '$vpath' . Please let me know the above is correct or suggest me the correct one. Thanks in advance. -Jerry (6 Replies)
Discussion started by: jerryragland
6 Replies

9. Programming

Include directive

Hi there, I'm working on a c++ project and I need to use some libraries which are part of a framework. I installed it on my home directory, and alle the .hh are located in subdirs of my home. I'd like to include the files I need just as if they where std c header, that is: #include... (2 Replies)
Discussion started by: clalfa
2 Replies

10. Programming

precompile directive?

hey everyone. havent posted here in a longgggg time. hope to see some familiar faces! heres my question, ive been doing basic programming in c++ again and want to use getch(). in *nix i have to use the curses library, and in windows conio.h is there a way i can have the compiler determine... (2 Replies)
Discussion started by: norsk hedensk
2 Replies
Login or Register to Ask a Question