Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cleaning log files

Posted on 2006-07-13
8
Medium Priority
?
2,256 Views
Last Modified: 2012-06-27
Hello

My /var is full. I need to list all the files with size attributes to clean unnecessary files manually

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3              4032124   4032120         0 100% /var

I need to > file.txt  the whole putput but dunno which linux command to use ?

Any help ?

Thank you. It is urgent so I m giving max points

thank you
tg
0
Comment
Question by:tgunduz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 8

Accepted Solution

by:
Autogard earned 400 total points
ID: 17103563
You mean "ls -lh /var > file.txt"?
0
 
LVL 35

Assisted Solution

by:Duncan Roe
Duncan Roe earned 400 total points
ID: 17103606
This is the command script I use to find large directories:

06:54:24$ cat `type -p vss`
#!/bin/sh
find . -mount -type d -mindepth 1 -maxdepth 1 -exec du -s "{}" \;

It shows the largest dir immediately below (at a guess, that will be log in your case if you run in /var)
cd to that large directory and repeat.
When vss doesn't show the size you saw in the previous level, you're in the dir with big files. Use "ls -lSr" to show the largest files (small ones will scroll off the screen:)
If they're system log files, best cat /dev/null > them. After you've cleaned up the mess, implement file size limioting in your logrotate config file.
0
 
LVL 4

Assisted Solution

by:bytta
bytta earned 400 total points
ID: 17108566
A simpler way do do the same (works on both files and dirs, unless hidden, like: /var/.name )

du -sc /var/* > file.txt
sort -nr file.txt | head -20 #show 20 largest files

cd to that large directory and repeat.
-c adds "total" disk space in the end of du output, which can help on subdirs

For ALL files and folders (errors ignored):
cd /var
du -sc * .[^.]* 2>/dev/null
0
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 
LVL 16

Assisted Solution

by:xDamox
xDamox earned 400 total points
ID: 17110092
Hi,

For cleaning your logs I would recommend editing the /etc/logrotate.conf file were you can have your logs compressed and
rotated daily, weekly, etc.
0
 
LVL 40

Assisted Solution

by:noci
noci earned 400 total points
ID: 17121742
If you don't have logrotate then you can probably find it with your distro, and otherwise with:
it has a good description at:

http://kavlon.org/index.php/logrotate
0
 
LVL 40

Expert Comment

by:noci
ID: 17121752
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question