[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Teach me, please!!!
Vu Thanh Ca wrote:
>
> Ca'm o+n hai ba'c Paul Pham va` DDa`m So+n. Tuy nhie^n, to^i dda~
> du`ng le^.nh df ma` kie^?m tra, ddi~a cu+'ng co`n i't nha^'t 100 MB.
> Ma` cu~ng kho^ng muo^'n mua the^m ddi~a cu+'ng vi` ca'i ma'y na`y
> dda~ bi. coi la` garbage ro^`i. To^i cho ra(`ng khi kho+?i ddo^.ng,
> ma^'y ca'i file message do' se~ ddu+o+.c load le^n bo^. nho+'. Bo^.
> nho+' la` 30 MB, ma` to^i chi? mo+'i xo'a co' 6MB tho^i, the^' ma` no'
> dda~ to^'t ro^`i. Ba'c na`o bie^'t the^m thi` chi? cho to^i nhe'.
>
> Ca.
ba'c ca,
ca'i shell script na`y ne^n dda(.t te^n la` remove
ba'c ta.o te^.p remove co' no^.i dung nhu+ sau :<>
ca'i te^.p na`y la` cu?a user Local ba'c pha?i su+?a la.i no^.i dung
cho phu` ho+.p vo+'i ba'c tho^i.
ddo^?i quye^`n cha.y te^.p cho remove va` chi? co' ba'c ddu+o+.c
ddo.c
ca:> chmod 700 remove
te^.p na`y ddu+o+.c thie^'t ke^' cho qua?n tri. ma.ng nho?
va` ddang ch.ay tre^n ma'y RedHat, SunOS 4.1.3 va` SunSolaris 2.5.1
ca:> remove
no' se~ kho^ng la`m gi` vo+'i ca'c user co' thu+ mu.c la`
Local/Mirror
no' se~ email ke^'t qua? cho user operator qua le^.nh mail
du` sao thi` SysAdmin cu~ng la` co^ng vie^.c kho^ng de^~
ne^'u ba'c thi'ch tui se~ gu+?i cho ba'c "hu+o+'ng da^~n ve^` SysAdmin"
chu'c ba'c tha`nh co^ng
#!/bin/sh
# script to remove those files which have not been accessed
# for two weeks and match the following
# 1) *~, *.rsl%
#
# for one week
# 2) *.aux, *.dvi, *.log, *.dlog, *.toc, and #* except those in
~/archive
# 3) ,* in /home/*/Mail
# 4) .raise_dump.*
# 5) ,*
#
# daily removing of core files
# 6) core
# 7) .netscape-cache
# 8) /disks/x3/space/pstmp
#
#-------------------------------------------------------------------------
# Create 2.1997 by ppn@iist.unu.edu
#-------------------------------------------------------------------------
#
# determine log file
wd=`date '+%a'`
ts=`date +%y%m%d%H%M%S`
f=/home/Local/removelogs/$ts
g=$f
touch $f
if [ ! -w $f ] ; then
f=/`date +%y%m%d%H%M%S`
touch $f
if [ ! -w $f ] ; then
f=/etc/`date +%y%m%d%H%M%S`
touch $f
if [ ! -w $f ] ; then
f=/dev/null
fi
fi
fi
if [ $f != $g ]; then
echo removed log file is $f | /usr/ucb/mail operator
fi
# make sure log file is empty
echo removed log file `date` > $f
# For files generated by LaTeX
cd /home
# two weekly removing
for d in *; do
if [ "$d" != "Mirror" -a "$d" != "Local" ]; then
find /home/$d/. \( -name '*~' -o -name '*.rsl%' \) \
-atime +14 -ls >> $f -exec rm {} \; -o \( -name archive
-prune \)
fi
done
# Weekly removing
cd /home
for d in *; do
if [ "$d" != "Mirror" -a "$d" != "Local" ]; then
find /home/$d/. \( -name '*.aux' -o -name '*.dvi' -o -name
'*.log' \
-o -name '*.dlog' -o -name '*.toc' -o -name '#*' \
-o -name '.raise_dump.*' \) \
-atime +7 -ls >> $f -exec rm {} \; -o \( -name archive
-prune \)
fi
done
#
# daily removing files
cd /home
for d in *; do
if [ "$d" != "Mirror" -a "$d" != "Local" ]; then
find /home/$d/. \( -name core \) \
-ls >> $f -exec rm {} \; -o \( -name archive -prune \)
fi
done
# For old mail messages: expiration time 7 days
for i in /home/*/Mail; do
find $i -name ',*' -atime +7 -ls >> $f -exec rm {} \;
done
# Delete .netscape/cache
for i in /home/*/.netscape/cache/*; do
#find $i -name '*' -ls >> $f -exec rm {} \;
echo $i >> $f
rm -r $i
done
# dailly removing pstmp files
for i in /disks/x3/space/pstmp/*; do
echo $i >> $f
rm -r $i
done
# clean up log file references, delete old log files
if [ $f = $g ]; then
/etc/chown local $f
oldlog=`ls -l /home/Local/removelogs/$wd | awk '{print $NF}'`
rm -f /home/Local/removelogs/$wd /home/Local/removelogs/$oldlog
(cd /home/Local/removelogs; ln -s $ts $wd)
chmod 444 $f
fi
# After removing finished, informing operator
echo removing completed | /usr/ucb/mail operator
# End of file remove