Skip to content

Instantly share code, notes, and snippets.

@mindfullsilence
Last active July 16, 2018 17:18
Show Gist options
  • Save mindfullsilence/9d169f7cf9a3eb8b800eb251a0ee8771 to your computer and use it in GitHub Desktop.
Save mindfullsilence/9d169f7cf9a3eb8b800eb251a0ee8771 to your computer and use it in GitHub Desktop.
Bash scripts to start and stop maintainance mode for wordpress.
#!/usr/bin/env bash
WP_WEB_ROOT=/var/www/html;
cd $WP_WEB_ROOT;
# Disable maintainance mode by removing the .maintainance file
rm -f $WP_WEB_ROOT/.maintainance;
# Flush caches
wp cache flush;
wp transient delete --all;
wp rewrite flush;
#!/usr/bin/env bash
WP_WEB_ROOT=/var/www/html;
# Maintenance mode file
MAINTENANCE='
<?php
$upgrade=time();
';
cd $WP_WEB_ROOT;
# creates a .maintainance file.
# Wordpress sees this and sets the site to maintainance mode.
echo $MAINTENANCE | tee $WP_WEB_ROOT/.maintainance;
# do maintainance stuff here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment