Solved

cleaning log files

Posted on 2006-07-13
8
2,237 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
Comment Utility
You mean "ls -lh /var > file.txt"?
0
 
LVL 34

Assisted Solution

by:Duncan Roe
Duncan Roe earned 100 total points
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 16

Assisted Solution

by:xDamox
xDamox earned 100 total points
Comment Utility
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 39

Assisted Solution

by:noci
noci earned 100 total points
Comment Utility
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 39

Expert Comment

by:noci
Comment Utility
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now