oguzhaninan / Stacer

Linux System Optimizer and Monitoring - https://oguzhaninan.github.io/Stacer-Web
GNU General Public License v3.0
8.87k stars 602 forks source link

Stacer's log cleaning breaks MySQL, Apache2 and Timeshift #425

Open xdpirate opened 3 years ago

xdpirate commented 3 years ago

Cleaning out logs with Stacer breaks MySQL, Apache2 and Timeshift.

Last week I tried out stacer and it seemed to work nicely, cleaned a few gigs of files, and didn't seem to have any ill effects. But today I tried to open my selfhosted webapp only to get a 404 on localhost. Dug through syslog to find that both apache2 and mysql services fail to start, because of the fact that their log folders no longer exist. The log and the date my Timeshift backups stopped indicate they have been failing since the day I ran Stacer.

Stacer seems to have removed these log folders these programs require to start up: /var/log/mysql/ for MySQL /var/log/apache2/ for Apache2

For Timeshift I'm unsure which path broke it, but I had to go through Timeshift's initial setup and reenable scheduled backups, it had not backed up since the day I ran Stacer last week.

To fix:

sudo mkdir /var/log/apache2/
sudo chmod -R 744 /var/log/apache2/
sudo mkdir /var/log/mysql/
sudo chown mysql:mysql /var/log/mysql/
sudo service mysql start
sudo service apache2 start

Running Kubuntu 20.04.1 LTS with Stacer from Ubuntu apt repo.

Suggested fix: When cleaning logs, only clean the log files and not their parent directory as the log directories are expected to exist with certain permissions and ownership, by many pieces of software.

kaiohken1982 commented 3 years ago

I confirm this. Same happens to supervisor and rabbitmq services, stacer should never delete logs dir.

xdpirate commented 3 years ago

Found out today that this also applies to Samba's log folder - /var/log/samba. Although Samba will still run normally without the log folder existing, it needs to be recreated manually to start logging again.

Jan 12 19:49:59 LPC smbd[397296]: [2021/01/12 19:49:59.734749,  0] ../../lib/util/debug.c:1098(reopen_one_log)
Jan 12 19:49:59 LPC smbd[397296]:   reopen_one_log: Unable to open new log file '/var/log/samba/log.smbd': No such file or directory
willyywt commented 3 years ago

It also breaks System Security Services Daemon (sssd): I don't know where it logs, but thet systemd journal says it's /var/log/sssd/sssd.log mkdir /var/log/sssd

willyywt commented 3 years ago

Also breaks audit.service mkdir /var/log/audit