Logrotate exclude log file


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Logrotate exclude log file
# 1  
Old 10-13-2017
Logrotate exclude log file

Hi all !

I've an issue to exclude a log file from logrotate, I tried this below:

Code:
/var/log/apache2/[!(*logfile_in_question*)]*.log {
        olddir /var/log/apache2/old
        missingok
        rotate 50
        compress
        copytruncate
        notifempty
        create 644 root root
}

I tried also:

Code:
/var/log/apache2/[!logfile_in_question]*.log

It doesn't work.. Can someone help me please ?Smilie

---------- Post updated 13-10-17 at 04:43 AM ---------- Previous update was 12-10-17 at 09:15 AM ----------

I solved my issue in adding these lines in the logrotate conf file:

Code:
        
prerotate
            bash -c "[[ ! $1 =~ log_in_question ]]"
endscript

Code:
/var/log/apache2/*.log {
        olddir /var/log/apache2/old
        rotate 50
        compress
        copytruncate
        notifempty
        create 644 root root
        prerotate
            bash -c "[[ ! $1 =~ log_in_questiong ]] && [[ ! $1 =~ log_in_question2 ]]"
        endscript
}

Bye ! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. Red Hat

File is missing after logrotate!!

I am having a requirement to rotate the my application logs dailay as it is keep on writiing to single file and below is the logrotate function which I am using, cat /apps/bmc/bmtm/QPasa_logrotate.conf /apps/bmc/bmtm/all_events.log /apps/bmc/bmtm/history_association.log { missingok ... (1 Reply)
Discussion started by: sandyrajh
1 Replies

4. UNIX for Dummies Questions & Answers

Explain this logrotate file

Very silly question .. I deleted it .. Please delete this thread too . (0 Replies)
Discussion started by: stunn3r
0 Replies

5. Shell Programming and Scripting

Help needed on Perl Script to Handle Log files that are rotated using logrotate

Hello all, I am working on a perl script which will read weblogic logfile and send the error messages to Zenoss Monitoring tool. At present the script works and it can able to send the error messages to Zenoss. The problem comes when the logrotate has been applied to the weblogic log file. At... (3 Replies)
Discussion started by: kar_333
3 Replies

6. Debian

Logrotate truncated my log files to 0 bytes and no logs are written

Hi, Yesterday I installed and configured logrotate on my Debian machine. I was expecting this to run at 06:25 in the morning and it actually did. All my old logs were compressed and zipped but the new logs were all with size equal to 0 bytes. Processes, while still running ok, they were not... (2 Replies)
Discussion started by: pmatsinopoulos
2 Replies

7. Ubuntu

[Solved] Using Find with an exclude/exclude file

I am familiar with using tar and exclude/include files: tar zcf backup.dirs.tgz --files-from=include.mydirs --exclude-from=exclude.mydirs --no-recursion but was wondering if I could use find in the same way. I know that you can just specify the directories to exclude but my list is... (2 Replies)
Discussion started by: metallica1973
2 Replies

8. UNIX for Advanced & Expert Users

rotate modsec log with logrotate in the global configuration

Hello Experts, I have an apache 2.2.17 on solaris 10 that I am not sure if I, could list the following in the global settings in httpd.conf. I tested it in the Virtual host section of httpd.conf and, it works but, not sure if I can do it in the global settings. Any help would be greatly... (0 Replies)
Discussion started by: afadaghi
0 Replies

9. UNIX for Advanced & Expert Users

how to logrotate log files

Hi, I have written a script that runs every five minutes in cron schedular. The Operating system is Fedora core 9. This script generates 2 log files, these log file size is increasing as some log data is being dumped into these 2 log files every five minutes. I need to logrotate these 2 files.... (1 Reply)
Discussion started by: renuka
1 Replies

10. 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
Login or Register to Ask a Question