サーバーのdiskの容量確認しsymfony cache をクリアする(shell)
サーバーに tv,video,gameというシステムがあり、サーバーのディスクの使用量が85%以上かつディスクの残量が10GB切ったらsymfonyのキャッシュをクリアする。
lists_system.txt
SYSTEMS=("tv" "video" "game")
cache_clear.sh
1 #!/bin/sh 2 # 3 #@(#)cache_clear.sh ver.1.0.0 2013.07.09 4 # 5 # Usage: 6 # cache_clear.sh CAPACITY AVAILABLE 7 # CAPACITY - Amount of disk capacity percentage. 8 # AVAILAVLE - Amount of disk Remaining quantity.(byte) 9 # SYSTEMS - listed system name at (../lists_system.txt) 10 # 11 # Description: 12 # if CAPACITY is greater than 85% and AVAILAVLE is less than 10GB, 13 # clear symfony cache in listed system. 14 # 15 # 16 17 . ./"lists_system.txt" 18 19 CAPACITY=`df -k /$home | tail -1 | /bin/sed 's/^.* \([0-9]*\)%.*$/\1/'` 20 AVAILABLE=`df -T /$home | tail -1 | awk '{print $4}'` 21 22 cd /home/user/src/${SYSTEMS[$n]}/CURRENT 23 24 n=${#SYSTEMS[@]} 25 n=$((n-1)) 26 while [ $n -ge 0 ]; 27 do 28 echo "$n ${SYSTEMS[$n]}" 29 cd /home/user/src/${SYSTEMS[$n]}/CURRENT 30 if [ $CAPACITY -gt 85 -a $AVAILABLE -lt 20971520 ]; then 31 php symfony cc 32 fi 33 n=$((n-1)) 34 done 35
これをcronで回せばいい。