Last active
August 3, 2020 08:22
-
-
Save sigismund/ab5ed86fc322d2d1ee5b7d451ce1e5f7 to your computer and use it in GitHub Desktop.
Check if wp action-scheduler ("cron") tasks are already running
This file contains 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 | |
SERVICE="wp-cli action-scheduler" | |
MAX_RUNNING_SCHEDULERS=3 | |
WP_CLI_PATH="/usr/local/bin/wp" | |
if (( $(ps aux | grep '/bin/wp action-scheduler' | grep -v 'grep' | wc -l) >= MAX_RUNNING_SCHEDULERS )) | |
then | |
echo "$SERVICE tasks are running at it's limit ($MAX_RUNNING_SCHEDULERS)." | |
else | |
echo "$SERVICE tasks are NOT running at it's limit ($MAX_RUNNING_SCHEDULERS)." | |
echo "$($WP_CLI_PATH run --batch-size=5 --batches=6 2>&1)" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment