Each my syslog file (and each new syslog) begins from this strings:
localhost rsyslogd: [origin software="rsyslogd" swVersion="8.2001.0" x-pid="451" x-info=""] rsyslogd was HUPed
localhost systemd[1]: logrotate.service: Main process exited, code=exited, status=1/FAILURE
localhost systemd[1]: logrotate.service: Failed with result 'exit-code'.
localhost systemd[1]: Failed to start Rotate log files.I have ubuntu 20 as VM on google cloud. How fix this errors? Thanks.
upd: output for systemctl status logrotate.service
● logrotate.service - Rotate log files Loaded: loaded (/lib/systemd/system/logrotate.service; static; vendor preset: enabled) Active: inactive (dead)
TriggeredBy: ● logrotate.timer Docs: man:logrotate(8) man:logrotate.conf(5) 5 1 Answer
If you have your Litespeed logs in a location outside of /var/log, then the log rotation service will not have write access to the files that need to rotate. You have two options to choose from:
- Move your Litespeed logs to a directory in
/var/log, such as/var/log/litespeed - Update the
logrotate.servicefile so the service can work with the log directory
Option 1 is pretty straightforward, so let's just look at the second item. This is how you can update the logrotate.service file:
- Open Terminal (if it's not already open)
- Open the
logrotate.servicefile asroot:
Note: Feel free to use a different editor if you prefer.sudo vi /lib/systemd/system/logrotate.service - Add the following line to the end of the file:
ReadWritePaths=/usr/local/lsws/logs - Save the file
- Restart the
logrotateservice:
Note: There is no output to this command.sudo systemctl daemon-reload && systemctl start logrotate
Why?
In the logrotate.service file is a line that reads ProtectSystem=full. When ProtectSystem is set as full it will mount everything as readonly except the directory where logs are stored on the system, such as /var/log. By adding additional directories via ReadWritePaths you allow the service to use those locations without limitations.
If you're really interested in learning more about this, the documentation breaks everything down in detail ... though it is a rather dry read.
1