Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save breakerh/5148b0b621577724f365bac29a712532 to your computer and use it in GitHub Desktop.
Save breakerh/5148b0b621577724f365bac29a712532 to your computer and use it in GitHub Desktop.
Magento 2 clean up
# Loop through all user directories in /home
find /home/ -type d \( -name "bin" -a ! -path "*/dev/tests/*" -a ! -path "*/vendor/magento/*" \) -exec find {} -type f -name "magento" \; | while IFS= read -r dir; do
processed_path=$(echo "$dir")
user=$(echo "$processed_path" | awk -F'/' '{print $3}')
echo "User: $user"
echo "Magento 2 installation found in: $processed_path"
echo "Emptying Magento 2 caches..."
php_version=$(ls -1 /usr/local/directadmin/data/users/"$(basename "$user")"/php/php-fpm*.conf | awk -F'php-fpm|.conf' '{print $2}' | sort -nr | head -1)
php_path="/usr/local/php$php_version/bin/php"
"$php_path" "$processed_path" cache:flush
wait $!
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment