Created
August 22, 2018 05:34
-
-
Save wokamoto/5830f64045d9a5884c2182f0fde5cb4a to your computer and use it in GitHub Desktop.
WordPress の cron event を wp-cli で実行するやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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