Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Created August 22, 2018 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wokamoto/5830f64045d9a5884c2182f0fde5cb4a to your computer and use it in GitHub Desktop.
Save wokamoto/5830f64045d9a5884c2182f0fde5cb4a to your computer and use it in GitHub Desktop.
WordPress の cron event を wp-cli で実行するやつ
#!/bin/bash
wp_root=${1:-/var/www/html}
wp="/usr/local/bin/wp --path=${wp_root}"
if [ ! -e ${wp_root} ]; then
echo "Not exists ${wp_root}"
exit 1
fi
lock_file="/var/tmp/doing_wp-cron.$(basename $wp_root)"
if [ -f ${lock_file} ]; then
exit
fi
if [ ! -e ${wp_root} ]; then
echo "Not exists ${wp_root}"
exit 1
fi
trap catch ERR
trap finally EXIT
function catch {
echo CATCH
}
function finally {
echo FINALLY
if [ -f ${lock_file} ]; then
rm -f ${lock_file}
fi
}
touch ${lock_file}
${wp} cron event run --due-now --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment