Skip to content

Instantly share code, notes, and snippets.

@jsonUK
Created August 21, 2017 16:57
Show Gist options
  • Save jsonUK/dc2525aae7e1e9ef7fab4fe2105c9b22 to your computer and use it in GitHub Desktop.
Save jsonUK/dc2525aae7e1e9ef7fab4fe2105c9b22 to your computer and use it in GitHub Desktop.
Clear the OpCache via the console
#!/bin/sh
# Gracefully Restart PHP7 FPM with SIGUSR2
# This clears PHP5 OpCache
if (kill -s USR2 `cat /var/run/php/php7.0-fpm.pid`) then
echo "Cleared PHP OpCache"
fi
@jsonUK
Copy link
Author

jsonUK commented Aug 21, 2017

If using Capistrano to clear caching, add the command to sudoers file (visudo to edit), then add this line:
deploy ALL=NOPASSWD: /usr/local/sbin/clear-opcache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment