Victor Kimura
asked on
Can I delete all the Linux log files or some of them? They are consuming a lot of disk space
Hi,
Just wondering if it's safe to delete some or all of the log files? Maybe back them up? They are consuming a lot of disk space on my VPS.
Should I be running some script to only save the latest logs from the server and limit the log files? If so, how do I do that?
I'm on Centos 5.9.
I ran this:
Thank you<><
Victor
Just wondering if it's safe to delete some or all of the log files? Maybe back them up? They are consuming a lot of disk space on my VPS.
Should I be running some script to only save the latest logs from the server and limit the log files? If so, how do I do that?
I'm on Centos 5.9.
I ran this:
du -a /var | sort -n -r | head -n 10
... (meaning there were a bunch of permission denied directories)
du: cannot read directory `/var/empty/sshd': Permission denied
du: cannot read directory `/var/lib/mysql': Permission denied
du: cannot read directory `/var/lib/dav': Permission denied
du: cannot read directory `/var/lib/dovecot': Permission denied
du: cannot read directory `/var/lib/mlocate': Permission denied
du: cannot read directory `/var/lib/pgsql': Permission denied
5990632 /var
2745120 /var/log
2579472 /var/spool
2579428 /var/spool/repackage
1711924 /var/log/brcm-iscsi.log
808244 /var/log/btmp
417972 /var/lib
200108 /var/log/chkservd.log
182264 /var/cpanel
118796 /var/cpanel/perl
Thank you<><
Victor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@serialband, ok. I just deleted all the *.rpm files in the /var/spool/repackage. Also deleted /var/log/brcm-iscsi.log.
I have WHM/cPanel. Are there any know problems/issues with running yum clean all?
---
Ok, thanks, NickUpson. Just reading this on the logrotate:
http://articles.slicehost.com/2010/6/30/understanding-logrotate-on-centos-part-1
I have this in the /var folder re. disk usage:
Should I delete the files like /var/lib/mysql/mysql-bin.0 00024, etc?
Looks like I have logrotate.
I have WHM/cPanel. Are there any know problems/issues with running yum clean all?
---
Ok, thanks, NickUpson. Just reading this on the logrotate:
http://articles.slicehost.com/2010/6/30/understanding-logrotate-on-centos-part-1
I have this in the /var folder re. disk usage:
root@ip-184-168-116-73 [/var/log]# du -a /var | sort -n -r | head -n 10 28511228 /var
27194204 /var/lib
26739776 /var/lib/mysql
1049608 /var/lib/mysql/mysql-bin.000024
1049608 /var/lib/mysql/mysql-bin.000022
1049608 /var/lib/mysql/mysql-bin.000021
1049608 /var/lib/mysql/mysql-bin.000020
1049608 /var/lib/mysql/mysql-bin.000019
1049608 /var/lib/mysql/mysql-bin.000018
1049608 /var/lib/mysql/mysql-bin.000017
Should I delete the files like /var/lib/mysql/mysql-bin.0
Looks like I have logrotate.
cd /etc/cron.daily
root@ip-184-168-116-73 [/etc/cron.daily]# ls -al
total 36
drwxr-xr-x 2 root root 4096 Oct 11 2013 ./
drwxr-xr-x 80 root root 12288 Sep 25 17:45 ../
-rwxr-xr-x 1 root root 180 Jun 4 2012 logrotate*
-rwxr-xr-x 1 root root 418 May 30 2012 makewhatis.cron*
-rw-r--r-- 1 root root 137 Jul 6 2011 mlocate.cron
-rwxr-xr-x 1 root root 296 Feb 25 2013 rpm*
-rwxr-xr-x 1 root root 354 Aug 11 2010 tmpwatch*
root@ip-184-168-116-73 [/etc/cron.daily]#
ASKER
My logrotate config settings. Does it look ok? Should I change or add anything in this config file? Considering I had massive logs I would think so but not quite sure what to add.
cd /etc/cron.daily
root@ip-184-168-116-73 [/etc/cron.daily]# ls -al
total 36
drwxr-xr-x 2 root root 4096 Oct 11 2013 ./
drwxr-xr-x 80 root root 12288 Sep 25 17:45 ../
-rwxr-xr-x 1 root root 180 Jun 4 2012 logrotate*
-rwxr-xr-x 1 root root 418 May 30 2012 makewhatis.cron*
-rw-r--r-- 1 root root 137 Jul 6 2011 mlocate.cron
-rwxr-xr-x 1 root root 296 Feb 25 2013 rpm*
-rwxr-xr-x 1 root root 354 Aug 11 2010 tmpwatch*
root@ip-184-168-116-73 [/etc/cron.daily]# cat logrotate
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
root@ip-184-168-116-73 [/etc/cron.daily]# cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files daily
daily
# keep 14 days worth of backlogs
rotate 14
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
minsize 1M
create 0664 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
root@ip-184-168-116-73 [/etc/cron.daily]#
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@gheist, I deleted the bcrm-iscsi log. Don't know what it was. I backed it up though in case I need it. It's not mentioned in the the /etc/logrotate.conf nor the /etc/logrotate.d/*.conf
@NickUpson, the rotate 14 seems to be set already.
I have WHM/cPanel. Are there any know problems/issues with running yum clean all?
Should I delete the files like /var/lib/mysql/mysql-bin.0 00024, etc?
@NickUpson, the rotate 14 seems to be set already.
I have WHM/cPanel. Are there any know problems/issues with running yum clean all?
Should I delete the files like /var/lib/mysql/mysql-bin.0
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all the feedback. Can you tell me what you fellows have for your log configuration? What commands do I use or scripts to rotate logs properly?
@gheist, you mentioned a log rotation pacakge. Which one? Command(s) to run? Still new to the linux admin stuff a bit.
@gheist, you mentioned before I delete any logs then I would need to restart a process? What process? What command(s) before deleting?
@serilalband mentioned run yum clean all. Any other commands suggested?
Thank you.