Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Logrotate service configuration (/etc/systemd/system/logrotate.service)

Featured Replies

Hello,
I am using Armbian 21.02.1 Focal with Linux 5.10.12-sunxi (Armbian Focal from https://www.armbian.com/orange-pi-zero/).

I use the default logrotate configuration (ratate logs in /var/log) but I have a problem that the /var/log/syslog file is still growing (even if logrotate is run daily). 
Currently the logrotate process takes place in 3 steps (see /etc/systemd/system/logrotate.service -> [Service] section):

1) ExecStartPre =/usr/lib/armbian/armbian-ramlog write (ramlog write files to update log.hdd before rotation) 
2) ExecStart =/usr/sbin/logrotate /etc/logrotate.conf (Logrotate)
3) ExecStartPost =/usr/lib/armbian/armbian-ramlog postrotate (ramlog postrotate (which will copy to/var/log the modified files of /var/log.hdd)

I think step 3 is wrong.


Assume that the following are performed during the logrotate:
1) ExecStartPre =/usr/lib/armbian/armbian-ramlog write  = ramlog write (to update log.hdd before rotation) - it is ok
2) the system writes another data to /var/log/syslog (at this moment /var/log/syslog <> /var/log.hdd/syslog)- that's ok
3) ExecStart =/usr/sbin/logrotate /etc/logrotate.conf = logrotate is performed (/var/log/syslog is renamed to /var/log/syslog.1, an empty /var/log/syslog is created, the system starts writing to the new empty /var/log/syslog). - it is OK
4) the system writes data to new /var/log/syslog (at this step /var/log/syslog is not empty) - that's ok
5) ExecStartPost =/usr/lib/armbian/armbian-ramlog postrotate = the ramlog postrotate is started. During postrotate are executed commands (cat /var/log.hdd/... > /var.log/...), which copy files from /var/log.hdd to /var.log). 
The command "cat $ file> $ dest" overwrites data in new /var/log/syslog with data from the old /var/log.hdd/syslog - so data written to syslog in step 4 is lost - this is a bug in my opinion

Another consequence of ramlog postrotate is that the new file /var/log/syslog is filled with the data that was written to syslog in the past (so the /var/log/syslog file is still growing).

 

Proposed solution is to change etc/systemd/system/logrotate.service -> [Service] section as follows:

[Service]
Type=oneshot
ExecStart=/usr/sbin/logrotate /etc/logrotate.conf
ExecStartPost=/usr/lib/armbian/armbian-ramlog write

 

There are no lost entries in the syslog in this solution.

  • Author

@tparys - thank you for your reply but I am new here, and I am not sure, if I am able to create pull request...

I noticed the same issue. I can submit a change. However, I am not familiar with armbian-ramlog program. So, I guess I will first see what this program does.

 

On my armbian I just commented out ExecStartPost in logrotate.service, and now logs are no longer rewritten with old data after rotation. I am not sure that is the correct way as I am not sure how it is supposed to rotate and archive logs.

  • Author

@noone - you commented out ExecStartPost -> so your logfiles are not written to the SD card  (/var/log.hdd). you will lost all your logs located in /var/log on power failure.

 

@noone - I made a mistake - commented out ExecStartPost is ok from my point of view.

  • Author

Hello, 

I registered that after upgrading to Armbian 21.05.1 the behaviour of /usr/sbin/logrotate /etc/logrotate.conf was changed.

Currently, step "3) ExecStart = /usr/sbin/logrotate /etc/logrotate.conf" is performed in the /var/log.hdd/ directory (in the previous version this step was performed in the /var/log directory).

 

So after the upgrade, I changed:
1) in /etc/logrotate.d/rsyslog:
/var/log.hdd/syslog -> /var/log/syslog

2) in the /etc/systemd/system/logrotate.service [Service] section as follows:
[Service]
Type = oneshot
ExecStart = / usr / sbin / logrotate /etc/logrotate.conf
ExecStartPost = / usr / lib / armbian / armbian-ramlog write

 

After these changes logrotate works according to my expectations again.

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.