Merhabalar

Windowsta bulunan disk temizleme özelliğini linuxa uyarlamışlar. Gereksiz log dosyaları gibi şeyleri temizliyor. Yabancı bir forumda buldum umarım işinize yarar.

#!/bin/bash
###################
# Disk Cleanup Script
# Originally by Gayan Gunasekara (gunemalli) / Revised by Joseph Fasone (r00ter)
# Adapted from http://neverthelost.net/site/2009/04/quick-and-easy-clean-up-for-cpanel-servers/
###################

## Defining locations
home=/root/
log=/root/diskcleanup

## Defining functions

function check {

if [ $? = "0" ]
then

echo -n "..." ;

sleep 1;
continue;

else

echo -n "...FAILED!"
sleep 5;
exit;

fi

}

function fcheck {

if [ $? = "0" ]
then

echo -n "...Done!" ;

else

echo -n "...FAILED!"
sleep 5;
exit;

fi

}

## Show the before Disk Usage.

df -h
sleep 3

## Yum works best when cleaned often I have noticed :)

echo -n "Cleaning YUM......."
yum clean all &>$log
fcheck
echo

#
## Remove all Compressed logs / remove any variations / incrementals
#

echo -n "Now removing files...."
sleep 1

for delete in \
'/var/log/*.gz' \
'/var/log/*.?' \
'/home/core.*' \
'/home/cpeasyapache' \
'/home/MySQL-install' \
'/home/latest' \
'/home/cprubygemsbuild' \
'/home/cprubybuild' \
'/home/cprestore' \
'/usr/local/cpanel/src/3rdparty/*' \

do

rm -rf $delete &>$log
check
continue

done
fcheck
echo

## Final commands..
cd /tmp &>log

for files in `ls`; do rm -f $files &>log; done;

echo -n "Now restarting MySQL..."
/etc/init.d/mysql restart &> log
fcheck

echo
echo
echo "New disk space"
df -h
echo
echo
echo "Disk Cleanup Complete!"
sleep 2

exit 0;