Clean Up Linux

Find Logs in VPS

/var/log/anaconda.log - Linux installation message
/var/log/audit/ - Directory of Linux audit daemon
/var/log/boot.log
/var/log/btmp - All unsuccessful login info
- Use lastb cmd to view details
/var/log/wtmp - All successful login info
- Use last cmd to view details
/var/log/lastlog - All login info
- Use lastlog cmd to view details
/var/log/chrony - Empty till now
/var/log/cloud-init.log - Not clear right now
/var/log/cron
/var/log/dmesg or /var/log/dmesg.old
/var/log/firewalld
/var/log/grubby and /var/log/grubby_prune_debug - Not clear
/var/log/hwbackup.log
/var/log/lastlog
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/shadowsocksr.log
/var/log/tallylog

/home/wwwlogs/access.log
/home/wwwlogs/nginx_error.log

Create A New Crontab task

1. Write a script

#cleanup.sh (Remember chmod +x cleanup.sh)
#!/bin/sh
cat /dev/null > /var/log/anaconda.log
cat /dev/null > /var/log/boot.log
cat /dev/null > /var/log/btmp
cat /dev/null > /var/log/wtmp
cat /dev/null > /var/log/lastlog
cat /dev/null > /var/log/firewalld
cat /dev/null > /var/log/lastlog
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/messages
cat /dev/null > /var/log/secure
cat /dev/null > /var/log/shadowsocksr.log

cat /dev/null > /home/wwwlogs/access.log
cat /dev/null > /home/wwwlogs/nginx_error.log

2. Edit crontab file

// Run cleanup.sh at 1:00 am everyday
// min hr day mon yr
0 1 * * * root run-parts /var/log/cleanup.sh

3. Add new task

// Edit
$ crontab -e
// View
$ crontab -l
// Remove
$ crontab -r