Script di Pulizia files dat di McAfee

From RVM Wiki
Revision as of 18:00, 3 June 2005 by Gabriele.vivinetto (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Questo script effettua la cancellazione delle firme dell'antivirus obsolete da più di $DAT_TO_KEEP versioni.


Creazione dello Script

cat > /root/bin/mcafee-clean <<'EOFile'
#!/bin/bash
# mcafee-clean v 1.0
#
# Cambiare DAT_TO_KEEP al bisogno
DAT_TO_KEEP=3
# ----------------------------------------------------------
# Fine parametri configurabili
# ----------------------------------------------------------
echo "Cancellazione McAfee Dat del $DATAOGGI"
cd /usr/local/uvscan/datfiles
RIGHE=$(/bin/ls -1d  4* | wc -l)
RIGHE_DA_CANC=$(($RIGHE - $DAT_TO_KEEP))
if (( $RIGHE > $DAT_TO_KEEP ))
        then
                for DAT in $(/bin/ls -1d  4* | head -n $RIGHE_DA_CANC)
                do
                        echo Deleting $DAT ...
                        /bin/rm -rf $DAT
                done
        else
                echo "Nothing to be deleted for today ..."
fi
EOFile

chmod 755  /root/bin/mcafee-clean

Modifcare il valore di DAT_TO_KEEP per cancellare più o meno versioni.


Installazione script

Lo script deve essere eseguito tutte le notti alle 03:10AM

cat >> /etc/crontab <<'EOFile'
10               3       *       *       *     root     /root/bin/mcafee-clean
EOFile

Esecuzione manuale dello script

Esempio di esecuzione:

mcafee-clean

Cancellazione McAfee Dat del
Deleting 4444 ...
Deleting 4445 ...
Deleting 4446 ...
...
Deleting 4500 ...
Deleting 4501 ...
Deleting 4502 ...