Solved

cleaning log files

Posted on 2006-07-13
8
2,252 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 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

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.…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

762 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