1

In a few days the auth.log on my Ubuntu 16.4.4 server has grown to 28 GB writing the following lines over and over again

Apr 14 21:31:29 Cloud systemd-logind[924]: Suspending...
Apr 14 21:31:29 Cloud systemd-logind[924]: Failed to execute operation: $

I know that this output is the result of me following the second answer here to prevent my laptop on which the server is installed from sleeping. I used the commandsudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target to accomplish this task. The question I am asking myself now is:

  • Is there a better way to accomplish my goal of preventing the system from sleeping that is completely CLI based?
  • How do I prevent this message from being logged over and over again?
ddominnik
  • 93
  • 1
  • 7

1 Answers1

4
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

Is the recommended way of preventing hibernation and sleep by debian. To get around the problem with /var/lib/auth.log growing to massive sizes, edit /etc/logrotate.d/rsyslog to add a maxsize 10M:

/var/log/syslog
{
    rotate 7
    daily
    missingok
    notifempty
    delaycompress
    compress
    postrotate
        /usr/lib/rsyslog/rsyslog-rotate
    endscript
 }

/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
    maxsize 10M
    rotate 4
    weekly
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
    postrotate
        /usr/lib/rsyslog/rsyslog-rotate
    endscript
}

You may also want to add a logrotate.timer to /etc/systemd/system in order to override the default one to run hourly instead of daily:

# /var/lib/auth.log was being filled to 7 GB due to hibernate.target being masked,
# which created a log entry very, very frequently. So /etc/logrotate.d/rsyslog was edited to set a
# maxsize of 10M for that log, and here we are going to run logrotate hourly
[Unit]
Description=Hourly rotation of log files
Documentation=man:logrotate(8) man:logrotate.conf(5)

[Timer]
OnBootSec=30s
OnUnitActiveSec=60m

[Install]
WantedBy=timers.target