Logrotate 0 byte file


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Logrotate 0 byte file
# 1  
Old 02-07-2020
Logrotate 0 byte file

Hello,

For various reasons I decided to rebuild my log server on a new microSD. To simplify matters I restored a backed up copy of the appropriate config files and uploaded them to the new log server once syslog-ng was setup. The issue I am running into now is when logrotate compresses the log file it compresses the file and either creates or leaves another one that 0 bytes.

In the syslog-ng file below I have tried to add nocreate and copytruncate and that didn't change a thing.

Code:
/var/log/mikrotik/mikrotik.*.log
{
        rotate 2
        daily
        compress
        missingok
        notifempty
        postrotate
                invoke-rc.d syslog-ng reload > /dev/null
        endscript
}

Reviewing the logrotate.conf file I see no indication of either create or copytruncate being uncommented. There has only been one day that the 0 byte file wasn't created and that was when I uncommented "create" saved and restarted syslog-ng and commented it out saved and restarted syslog-ng but it came back the nexdt night.

Code:
# see "man logrotate" for details
# rotate log files weekly
daily

# keep 4 weeks worth of backlogs
rotate 2

# create new (empty) log files after rotating old ones
#create

# uncomment this if you want your log files compressed
compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0660 root utmp
    rotate 1
}

# system-specific logs may be configured here


Why is this file being left/created? Am I missing a file somewhere or is there something in the config that causing this issue. I also do not have this provlem on the log server that the config files were copied from which is why i am at a loss. I don't want to just



Syslog-ng.conf

Code:
@include "scl.conf"

# Syslog-ng configuration file, compatible with default Debian syslogd
# installation.

# First, set some global options.
options { chain_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no);
          owner("root"); group("adm"); perm(0644); stats_freq(0);
          bad_hostname("^gconfd$");
};

# Accept connection on UDP
source s_net { udp (); };

# MIKROTIK ###########
# Add Filter to add our mikroti
filter f_mikrotik { host( "192.168.88.1" ); };
# Add destination file where logs will be stored
#destination df_mikrotik { file("/home/pi/files/mikrotik.log"); };
log { source ( s_net ); filter( f_mikrotik ); destination ( df_mikrotik ); };
destination df_mikrotik {
file("/var/log/mikrotik/mikrotik.${YEAR}.${MONTH}.${DAY}.log"
template-escape(no));
};

########################
# Sources
########################
# This is the default behavior of sysklogd package
# Logs may come from unix stream, but not from another machine.
#
source s_src {
       system();
       internal();
};

# 2  
Old 02-08-2020
logrotate is awful.
Code:
man logrotate

does not well enough clarify boarder cases.
Try to add
sharedscripts
This ensures that the postrotate action occurs once.
It work as well (or even better) to replace postrotate with lastaction (then you do not need sharedscripts).
This User Gave Thanks to MadeInGermany For This Post:
# 3  
Old 02-08-2020
Thanks, going to give a try!
# 4  
Old 02-10-2020
So two mornings in a row now and my 0 byte files are not present. Thank you very much.
This User Gave Thanks to MyUserName7000 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Logrotate exclude log file

Hi all ! I've an issue to exclude a log file from logrotate, I tried this below: /var/log/apache2/*.log { olddir /var/log/apache2/old missingok rotate 50 compress copytruncate notifempty create 644 root root } I tried also:... (0 Replies)
Discussion started by: Arnaudh78
0 Replies

2. Solaris

How to logrotate a file after X days with logadm?

Hi Guys - We have the /var/adm/pacct file currently configured to log rotate using logadm - here is the entry in logadm.conf: /var/adm/pacct -C 0 -N -P 'Wed Oct 23 08:00:00 2013' -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never Just want to ask if it would like possible to... (1 Reply)
Discussion started by: akaterasu
1 Replies

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

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

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

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

7. Shell Programming and Scripting

How to give the zip file name in logrotate?

Hi, How to give file name for the zip file while compressing in logrotate... Should we need to give it in the logrotate.conf file or in the spec file...? (2 Replies)
Discussion started by: Dedeepthi
2 Replies

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

9. Shell Programming and Scripting

Remove a byte(Last byte from the last line)

Hi All Can anyone please suggest me how to remove the last byte from a falt file .This is from the last line's last BYTE. Please suggest me something. Thank's and regards Vinay (1 Reply)
Discussion started by: vinayrao
1 Replies

10. Shell Programming and Scripting

Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server. For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match. Please... (4 Replies)
Discussion started by: krishmaths
4 Replies
Login or Register to Ask a Question