Skip to content

Instantly share code, notes, and snippets.

@adrian-green
Last active October 25, 2021 03:32
Show Gist options
  • Save adrian-green/b839b009e3775938cbba68a9c8ec897e to your computer and use it in GitHub Desktop.
Save adrian-green/b839b009e3775938cbba68a9c8ec897e to your computer and use it in GitHub Desktop.
#!/bin/bash
# adjust to suit
MODE=live
SITE=https://full.site.domain/
WEBDIR=/srv/magento/${MODE}/www/pub/
# generate a 20 char random file name (will be removed)
RANDOM_SCRIPT_NAME=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 20)
# write temp file
echo "<?php opcache_reset(); ?>" > ${WEBDIR}${RANDOM_SCRIPT_NAME}.php
# issue curl request to flush the opcache under web server context
curl http://${SITE}/${RANDOM_SCRIPT_NAME}.php
# clean up
rm ${WEBDIR}${RANDOM_SCRIPT_NAME}.php
echo "cache reset"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment