Solved

cleaning log files

Posted on 2006-07-13
8
2,243 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
8 Comments
 
LVL 8

Accepted Solution

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

Assisted Solution

by:Duncan Roe
Duncan Roe earned 100 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 100 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 16

Assisted Solution

by:xDamox
xDamox earned 100 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 100 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
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.…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

777 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