Mittwoch, 25. August 2010 von sägefisch
Um durch etwaige Cronjobs eine Prüfung von 2 Dateien und darauf folgende Aktionen zu erzeugen, kann ein shell script Verwendung finden.
#!/bin/bash
SOURCE=/mount/data/new_file.txt
TARGET=/srv/www/vhosts/www/app/config/old_file.txt
diff -i -b -B -q ${SOURCE} ${TARGET}
if [ ! $? -eq 0 ]
then
echo "new file is different from old one - copy new one to old"
cp ${SOURCE} ${TARGET}
else
echo "no difference between files - nothing to do"
fi
Tags:bash, copy, diff, script, Shell, source, target
Abgelegt in Deployment, Linux, Server, Shell | Keine Kommentare »
Mittwoch, 02. Dezember 2009 von sägefisch
Hier findet Ihr den Shell Scripting Guide:
freeos.com/guides/lsst/
Dann kann man beispielsweise so kleine Helferlein zum Löschen von Logs und Caches wie diesen hier basteln:
#!/bin/bash
cd `dirname $0` # go to scripts dir
cd .. # step ahead
arr[0]='Application1/app/cache/*'
arr[1]='Application1/var/cache/*'
arr[2]='Application2/application/cache/*'
arr[3]='Application2/application/logs/*'
arr[4]='Application2/pub/tmp/*'
arr[5]='Application3/application/cache/*'
arr[6]='Application3/application/logs/*'
arr[7]='Application3/pub/tmp/*'
i=0
while [ $i -lt ${#arr[@]} ]
do
rm -rf ${arr[$i]}
echo "${arr[$i]} deleted"
(( i=$i+1 ))
done
Tags:bash, bin, freeos, guide, Linux, scripting, Shell, ssh
Abgelegt in Deployment, Linux, Server, Shell | Keine Kommentare »