Skip to content

Instantly share code, notes, and snippets.

@fulopattila122
Last active February 25, 2016 08:34
Show Gist options
  • Save fulopattila122/1514e945d4bef417ee1d to your computer and use it in GitHub Desktop.
Save fulopattila122/1514e945d4bef417ee1d to your computer and use it in GitHub Desktop.
Symfony Cache Cleaner (keeps sessions, also clears redis, resets permissons)
#!/bin/bash
[ ! -d app/cache/prod ] && echo "No [app/cache/prod] folder waz found here" && exit 1
sudo echo "Symfony Cache Cleaner" || exit 1
echo -n "Clearing folder [app/cache/prod] (except for sessions)..."
ls app/cache/prod/ | grep -v sessions | grep -v feed | tr '\n' '\0' | xargs -0 -L1 -I '$' sudo rm -rf 'app/cache/prod/$'
echo OK
echo -n "Re-crating the hateoas folder..."
[ ! -d app/cache/prod/hateoas ] && mkdir app/cache/prod/hateoas && chown www-data.www-data app/cache/prod/hateoas
[ $? == 0 ] && echo OK
echo -n "Re-crating the jms_serializer folder..."
[ ! -d app/cache/prod/jms_serializer ] && mkdir app/cache/prod/jms_serializer && chown www-data.www-data app/cache/prod/jms_serializer
[ $? == 0 ] && echo OK
echo -n "Resetting permissions for www-data..."
sudo chown -R .www-data app/cache app/logs
sudo chmod -R g+w app/cache app/logs
echo OK
echo -n "Clearing redis cache..."
redis-cli flushdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment