Recently I was facing a Magento installation that has it’s Cache in a RAM-Disk to enhance the performance of the shop. From time to time the Cache-Drive was filling up to the max and we decided to monitor it via a little shell script. As soon as a certain size is reached, the Magento-Cache get’s emptied and the administrator is informed about it. The script can be run daily or more often, depending on your setup.
TO="mail@example.org"
SUBJ="Magento Cache Disk"
# Limit is 200M as the disk contains 256M in max
SIZE="204800"
# check the current size
CHECK=$(df | grep cache | awk '{print $3}')
if [ "$CHECK" -gt "$SIZE" ]; then
rm -rf /path/to/your/magento/var/cache/*
echo "Cache Disk was $CHECK Bytes big and thus emptied" | mail -s "$SUBJ - emptied" "$TO"
else
# echo "Cache Disk was $CHECK Bytes big and not emptied" | mail -s "$SUBJ - no action taken" "$TO"
exit 1
fi
Nice to see, that such stuff can easily be automated with a little shell script.
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.