# Cleaning up audit logs on solaris
# Source: http://docs.sun.com/app/docs/doc/816-4557/audittask-12?a=view
# List the files with the not_terminated string on your audit file system in order of creation.
ls -R1t audit-directory*/files/* | grep not_terminated
# -R Lists files in subdirectories.,-t Lists files from most recent to oldest.,-1 Lists the files in one column.
# Clean up the old not_terminated file.Specify the name of the old file to the auditreduce -O command.
auditreduce -O system-name old-not-terminated-file
# Remove the old not_terminated file.
rm system-name old-not-terminated-file
# Finding Disk Utilisation
df -k
or
du -sk * |sort -rn | head
or
du -k * |sort -rn | head
# For Solaris servers.To check usage in current filesystem/device
du -dk <filesystem> | sort -rn | head
#eg.
du -dk /opt/sunone61 | sort -rn | head
#For reverse sorting by size
ls -lSr
or
du | sort -nr | cut -f2- | xargs du -hs | head
or
du | sort -nr | cut -f2- | xargs du -s | head
#Find the Top 10 biggest directories under /
du -kod / |sort -n | tail -10
# Reverse sort by change date
ls -ltr
# Finding Directory sizes
du -sh folder_name
du -ch folder_name
du -csh folder_name
# List files and ignore .gz files
ls -lah | grep -v '.gz$'
# Finding files above 100 Mb
find / -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
find / -type f -size +100000k
# Find 10 largest directores in current directory
du -hs */ | sort -hr | head
# To move files older than 90 days in the current directory and move them to /tmp folder
# in current and sub directories
find . -type f -mtime +90 -exec mv {} /tmp \;
# In current directory only
find . -maxdepth 1 -type f -mtime +90 -exec mv {} /tmp \;
To move *.gz files older than 90 days in the current directory and move them to /tmp folder
find . -type f -mtime +90 -name "*.gz" -exec mv {} /tmp/ \;
# To delete files older than 90 days in the current directory
find . -mtime +90 -exec rm {} \;
# To delete files named core.fmd.* in the current directory
find . -type f -name "core.fmd.*" -exec rm {} \;
# To find all files having log in the file name and older than 30 days in the location /
find / -mtime +30 -type f -name "*.log.*" -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
# To compress all files having log in the file name and older than 30 days in the location /
find / -mtime +30 -type f -name "*.log.*" -exec gzip {} \;
# Compressing and nullyfying a file in one go
cp -a /<path>/<file_name> /tmp && cat /dev/null > /<path>/<file_name> && gzip /tmp/<file_name> && mv /tmp/<file_name>.gz /<path>
Monday, April 14, 2008
Dealing with large files and directories in Linux/Unix
Subscribe to:
Post Comments (Atom)
2 comments:
i use the commands and its works. very informative. thanks a lot.
nice blog
Post a Comment