logrotate

Logrotate without root user access not working

Logrotate without root user access not working The problem is that we don’t have EASY root access to servers. That’s why being able to run logrotate without being root is very handy. This is what I did after following articles on the internet. Create a directory /home/techyman/logrotate with two files logrotate.conf and logrotate.status Put your …

Total answers: 1

Correct config to delete files after 7 days?

Correct config to delete files after 7 days? Is this the correct config to delete files after 7 days using logrotate? It should rotate weekly. I’m pretty stumped on this one. Thanks. /var/lib/rundeck/logs/rundeck/*/job/*/logs/*.blah.json { su root root weekly missingok maxage 7 rotate 0 nocreate } Asked By: Gru || Source The config as presented suggests …

Total answers: 1

How to automatically change the name of a file on a daily basis

How to automatically change the name of a file on a daily basis I am new to Linux/CentOS and right now I am running into a little problem. My CentOS7 Server logs all Maillogs on a daily basis and moves them to the folder /var/log/old_maillogs. Right now the logs are saved with a name similar …

Total answers: 1

Logrotation has different behaviors when reading from "/etc/logrotate.conf" and "/etc/logrotate.d/*conf" files

Logrotation has different behaviors when reading from "/etc/logrotate.conf" and "/etc/logrotate.d/*conf" files We need to keep only one log file of each service in our Ubuntu 20.04 servers. I’ve modified the /etc/logrotate.conf file as follows: weekly su root adm rotate 0 create ifempty include /etc/logrotate.d And for a specific service, think of misc for example, which …

Total answers: 1

How to delete old log files with logrotate

How to delete old log files with logrotate In my CentOS, there is a Logstash, which generate many log files. Here is how the log files look like: logstash-2023-03-09.log logstash-2023-03-20.log logstash-deprecation-2023-03-08-1.log.gz logstash-plain-2023-03-14-1.log.gz logstash-plain-2023-03-25-1.log.gz logstash-2023-03-10.log logstash-2023-03-21.log logstash-deprecation-2023-03-09-1.log.gz logstash-plain-2023-03-15-1.log.gz logstash-plain-2023-03-26-1.log.gz logstash-2023-03-11.log logstash-2023-03-22.log logstash-deprecation-2023-03-10-1.log.gz logstash-plain-2023-03-16-1.log.gz logstash-plain-2023-03-27-1.log.gz logstash-2023-03-12.log logstash-2023-03-23.log logstash-deprecation.log logstash-plain-2023-03-17-1.log.gz logstash-plain-2023-03-28-1.log.gz logstash-2023-03-13.log logstash-2023-03-24.log logstash-json.log logstash-plain-2023-03-18-1.log.gz logstash-plain.log logstash-2023-03-14.log logstash-2023-03-25.log …

Total answers: 1

How many times will postrotate run when defining logrotate for multiple directories?

How many times will postrotate run when defining logrotate for multiple directories? I have the below configuration for rotating the DB backups. The /var/mysql_backup/data/ contains two subdirectories db1 and db2. /var/mysql_backup/data/*/db.sql.gz { daily rotate 7 nocompress notifempty missingok create 640 root root dateext dateformat _%Y_%m_%d_%s extension .sql.gz postrotate PATH=/var/mysql_backup/data/ MYSQL_USER=USER MYSQL_PASS=’PASS’ MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}" MYSQLDUMP_OPTIONS=" –single-transaction …

Total answers: 1

Trying to rotate logs however tee command fails to return after execution

Trying to rotate logs however tee command fails to return after execution My logs nohup.out is owned by root user while I m trying to rotate the logs using system which has privileged access using sudo I have written the below script to rotate logs. cat rotatelog.sh cp /var/www/html/nohup.out /var/www/html/nohup.out_$(date "+%Y.%b.%d-%H.%M.%S"); sudo tee /var/www/html/nohup.out; The …

Total answers: 1

Ubuntu 22.04: Logrotate not working after upgrade to Ubuntu 22.04

Ubuntu 22.04: Logrotate not working after upgrade to Ubuntu 22.04 I just realized that since the upgrade to 22.04.1, logrotate is not working. Syslog hasn’t been rotated for many days. It’s supposed to be run by systemd timers, and the related timer is activated: # systemctl list-timers NEXT LEFT LAST PA> Thu 2022-09-15 23:09:00 CEST …

Total answers: 1

How to properly logrotate logs of service managed by systemd via `file:` config

How to properly logrotate logs of service managed by systemd via `file:` config I have a service managed by systemd that has the following systemd config telling systemd to write the logs to a file directly (no syslog or anything) StandardOutput=file:/var/log/foo/my.log I have a logrotate rule /var/log/foo/*.log { rotate 31 daily missingok notifempty compress delaycompress …

Total answers: 2

How to check logrotate syntax?

How to check logrotate syntax? We are suspecting a typo in the /etc/logrotate.d/FOO file. How can we check it? So far I can see from: https://linux.die.net/man/8/logrotate maybe this?: logrotate -df /etc/logrotate.d/FOO 2>&1 | grep -i error Asked By: BenB1992 || Source The logrotate syntax can be verified before with the flag -v logrotate -vf /etc/logrotate.d/FOO …

Total answers: 2

How does logrotate work?

How does logrotate work? I’m really struggling to understand how logrotate works when running a command within a shell file of my own, and how it doesn’t. The command in question is: rclone -L -vv –log-file “/home/mike/tmp/qqq.log” sync “/media/mike/W10 D drive/My Documents/” remote:MyDocuments_M17A_from_Linux What I would like: I would like this qqq.log file to be …

Total answers: 2

How copytruncate actually works?

How copytruncate actually works? we would like to understand copytruncate before rotating the file using logrotate with below configuration: /app/syslog-ng/custom/output/all_devices.log { size 200M copytruncate dateext dateformat -%Y%m%d-%s rotate 365 sharedscripts compress postrotate /app/syslog-ng/sbin/syslog-ng-ctl reload endscript } RHEL 7.x, 8GB RAM, 4 VCpu Question: How does logrotate truncate the file, when syslog-NG already opened file for …

Total answers: 1

Why is kill -HUP used in logrotate in RHEL? Is it necessary in all cases?

Why is kill -HUP used in logrotate in RHEL? Is it necessary in all cases? I see for syslog logging, kill -HUP is used. /var/log/cron /var/log/maillog /var/log/messages /var/log/secure /var/log/spooler { sharedscripts postrotate /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true endscript } I understood that -HUP is used because daemons like syslog, when …

Total answers: 2

How can I properly override logrotate policies?

How can I properly override logrotate policies? Various Debian packages, including logrotate and rsyslog, put their own log rotation definitions in /etc/logrotate.d/ What is the correct way to override those definitions? If I modify the files, I get warnings at every system update and I risk losing the changes if I (or someone else) give …

Total answers: 4

Ignoring /etc/logrotate.conf because of bad file mode

Ignoring /etc/logrotate.conf because of bad file mode How can I do logrotate? I can see no effect when I do logrotate: root@me-Latitude-E5550:/etc/logrotate.d# cd .. root@me-Latitude-E5550:/etc# cd .. root@me-Latitude-E5550:/# logrotate -d /etc/logrotate.conf Ignoring /etc/logrotate.conf because of bad file mode. Handling 0 logs root@me-Latitude-E5550:/# chmod 644 /etc/logrotate.d/* root@me-Latitude-E5550:/# cd /etc/logrotate.d root@me-Latitude-E5550:/etc/logrotate.d# ls apport custom pm-utils speech-dispatcher upstart …

Total answers: 2

How to tar-gz all files older than 28 days in a directory?

How to tar-gz all files older than 28 days in a directory? Every day I’m deleting log files in a folder. find ~/folder -mtime +28 -type f -delete Now I would like to archive and compress all files affected by above delete command and store this tar.gz in a new directory folder2. So let’s assume …

Total answers: 1

logrotation – rotate and maxage command

logrotation – rotate and maxage command Can anybody please explain me about the function of ‘rotate’ and ‘maxage’ in logrotation as this is very confusing . consider am using the below values in my script: rotate 30 maxage 30 Thank you.. Asked By: Abhilash || Source Both of them define how many logfiles you want …

Total answers: 1

Nginx Log Rotation Doesn't Seem to Be Working Correctly

Nginx Log Rotation Doesn't Seem to Be Working Correctly I discovered that my partition mounted as /var had filled up. In tracking down the disk usage, I found that my Nginx log file is huge, and it doesn’t seem to be writing to the correct file. ls -ltr in /var/log/nginx gives me this: total 17170060 …

Total answers: 1