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
  • 83
  • 7
  • What did you actually do - claiming to follow remote instructions (with an unknown degree of accuracy in following the instructions) does not tell us what you actually did, what happened, and what went wrong. And, you asked two questions, but you're only allowed one question per Question. – waltinator Apr 14 '18 at 20:00
  • I masked sleep.target, suspend.target, hibernate.target and hybrid-sleep.target to prevent my system from going to sleep or hibernating so my server-processes are always running. The problem is that suspend.target logs that it is masked now over and over again, which is making the size of the file huge and pollutes it so I can't find any other important info I might need – ddominnik Apr 14 '18 at 20:04
  • Have you tried just disabling those services instead of masking them? – Zanna Apr 18 '18 at 11:50
  • These are targets, not services and disabling targets doesn't work. – therealjumbo Nov 19 '19 at 18:09

1 Answers1

3
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