Jump to content
 English      
???en.wpa.text.hpweb2003.home??? ???en.wpa.text.hpweb2003.prodserv??? ???en.wpa.text.hpweb2003.support??? ???en.wpa.text.hpweb2003.solutions??? ???en.wpa.text.hpweb2003.buy???
» ???en.wpa.text.hpweb2003.contact???
     Forums advanced search
HP.com Home
IT Resource Center Forums > Linux > system administration

cleaning up /var

» 

IT Resource Center

» Login
» Register
» My profile
» Search knowledge base
» Forums
» Patch database
» Download drivers, software and firmware
» Warranty check
» Support Case Manager
» Software Update Manager
» Training and Education
» More maintenance and support options
» Online help
» Site map

Member icons
 
 HP moderator  HP moderator
 Expert in this area  Expert in this area
Member status
ITRC Pro ITRC Pro
250 points
ITRC Graduate ITRC Graduate
500 points
ITRC Wizard ITRC Wizard
1000 points
ITRC Royalty ITRC Royalty
2500 points
ITRC Pharaoh ITRC Pharaoh
7500 points
Olympian Olympian
20000 points
1-Star Olympian 1-Star Olympian
40000 points
2-Star Olympian 2-Star Olympian
80000 points
»  How to earn points
»  Support forums FAQs
Question status
Magical answer Magical answer
Message with a response that solved the author's question
Favorites status
Add to my favorites Add to my favorites
Delete from my favorites Delete from my favorites
This thread has been closed Thread closed
 

Content starts here
   Create a new message    Receive e-mail notification if a new reply is posted  Reply to this message
Author Subject: cleaning up /var      Add to my favorites
Waqar Razi
Oct 14, 2009 18:28:10 GMT   

I have a question about cleaning up of /var on linux. Like we trim the syslog.log and other log files in hpux and then just save the old ones in compressed form. What approach we should adopt in RHEL because in RHEL, they have /var/log/message, message1, 2, and 3. What other things can we check if we are cleaning up /var on RHEL.
Note: If you are the author of this question and wish to assign points to any of the answers, please login first.For more information on assigning points ,click here


Sort Answers By: Date or Points
Waqar Razi
Oct 14, 2009 18:29:34 GMT    N/A: Question Author

Just to add some thing to my post,

-rw-r----- 1 root root 370199688 Oct 14 11:28 messages
-rw-r----- 1 root root 785214202 Oct 11 04:07 messages.1
-rw-r----- 1 root root 790338206 Oct 4 04:07 messages.2
-rw-r----- 1 root root 790509595 Sep 27 04:07 messages.3
-rw-r----- 1 root root 790481660 Sep 20 04:07 messages.4
Ivan Ferreira This member has accumulated 20000 or more points
Oct 14, 2009 19:41:28 GMT    Unassigned

In RHEL the logrotate program is used to rotate/keep versions of your file. In the logrotate.conf you can specify how much versions you want to keep, and other files to rotate.

You should also check /var/spool/ directory, there are some "spool" files like mail and printing files that should be handled. For example, if no one ever reads that root mail, you will have a big file there.

Just run du -sh * in the /var directory to identify where you get the most big directory.
D. Jackson This member has accumulated 500 or more points
Oct 15, 2009 00:46:24 GMT    Unassigned

Do a du -sk /var and go from there.
Probably some stuff under /var/spool/up2date.
Runar Jørgensen
Oct 15, 2009 10:42:57 GMT    Unassigned

There should also be some available space occupied by the rpm database. The database can be trimmed if you know how, e.g. redundant, i.e. old, versions of packages could be removed from the database. Unfortunately, I'm not too familiar with how. But perhaps the forum can aid.
loco_vikide
Oct 15, 2009 13:44:21 GMT    Unassigned

Hello,

First, modify the config file /etc/logrotate.conf. Turn on "compress" feature, change "rotate" value, "minsize" value and "weekly" log rotate value to fit your needs.

Take a look at directory /var/log and decide which logs you want to trim on frequent basis. Most to all of them could be trimmed. Then add the log file entries in the config file /etc/logrotate.d/syslog

Run the find command against "/var" mount point to discover other log files that could be candidates for trimming.

Run man logrotate command for more info on logrotate function.

Cheers.
Ralph Grothe This member has accumulated 2500 or more points
Oct 15, 2009 14:14:25 GMT    Unassigned

Like Ivan mentioned,
almost any Linux distro today uses the logrotate program for rotation of most of the log files on their system (of which most will be found in subdirs named according to their services beneath /var/log)

Especially, on RHEL systems you have the main configuration in /etc/logrotate.conf which merely is a stub for global settings and the wtmp file.

Here, for instance is mine, which is almost the original as installed (except for the tabooext entries)

# grep ^[^#] /etc/logrotate.conf
weekly
rotate 4
create
tabooext + .dormant .deferred .stalled
include /etc/logrotate.d
/var/log/wtmp {
    monthly
    create 0664 root utmp
    rotate 1
}


As you can see, it globally defines to keep 4 rotated generations of log files (unless overridden in a later curly bracketed section.
Also note that this global config includes all files that don't end in tabooext suffixes from the directory /etc/logrotate.d,
and this is the place where you will find more specific definitions for most of the services that keep log files.
For instance, the messages file's rotation is defined in /etc/logrotate.d/syslog

# cat /etc/logrotate.d/syslog
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

As you can see, all the files listed to the left of the opening curly bracket will be affected by what follows in the block.

If you wish to have your rotate log files to be compressed just place the "compress" keyword in the block, and if you want to keep fewer than 4 generations insert an e.g. "rotate 2" there (rotate 0 would keep no old copies)
As you can see from the timestamps of your rotate logs the global default of "weekly" rotations applies.
If you require more frequent rotations put the "daily" keyword in the syslog's config block.

There are lots of further keywords that influence the rotation scheme.
Please consult "man logrotate".

The execution of logrotate is controlled by cron.
In the system's main crontab you will find these entries

# grep run-parts /etc/crontab
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly


of which /etc/cron.daily/logrotate eventually executes the logrotate command on a daily basis


# cat /etc/cron.daily/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


After your changes to any of the logrotate config files you ought to run a pre-flight check by issuing e.g.

# /usr/sbin/logrotate -d /etc/logrotate.conf

The debug option will only examine which files would be due to a be rotated and print what it would do but actually wouldn't touch any of the files.
d_allen111
Nov 6, 2009 13:43:45 GMT    Unassigned

Ralph - Would you please show an example how you would add the "compress" and "Daily" within the block in syslog you've mentioned??

I am very interested in learning more on how we can rotate these log files and compressed them as needed.

Thanks,

David


cat /etc/logrotate.d/syslog
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
Johnson Punniyalingam This member has accumulated 2500 or more points
Nov 7, 2009 17:44:28 GMT    Unassigned Attachement is 344424.ppt 

Hi Waqar Razi,

Can you Check "MS Power point" attachment file

which has been created by "Dusan Baljevic
"

which give better picture how to maintain System Logs

Thanks,
Johnson
 
Create a new message    Receive e-mail notification if a new reply is posted   Reply to this message
 
 
Printable version
Privacy statement Using this site means you accept its terms
© 2009 Hewlett-Packard Development Company, L.P.