Created
July 4, 2017 19:31
-
-
Save kgroveshok/c95a40ed016a4e9dcb208494e62f852d to your computer and use it in GitHub Desktop.
Prevent Mautic crons from clashing with one another
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/sh | |
# provide blocking to prevent duplicates | |
echo $$ | |
LOCKFILE=/tmp/mautic.lock | |
if [[ -a $LOCKFILE ]] ; then | |
echo "Already running?" | |
# check to see if the pid is running | |
PID=`cat $LOCKFILE` | |
kill -0 $PID >/dev/null 2>&1 | |
if [[ $? -ne 0 ]] ; then | |
# it is done so clear lock | |
echo "All done so clear for next time" | |
rm -f $LOCKFILE | |
else | |
echo "Still running" | |
fi | |
exit | |
else | |
echo $$ >$LOCKFILE | |
echo "Run scripts" | |
chown apache.apache /var/www/mautic/app/logs/* | |
/usr/bin/php /var/www/mautic/app/console mautic:segments:update >/dev/null 2>&1 | |
/usr/bin/php /var/www/mautic/app/console mautic:campaigns:rebuild >/dev/null 2>&1 | |
/usr/bin/php /var/www/mautic/app/console mautic:campaigns:trigger >/dev/null 2>&1 | |
/usr/bin/php /var/www/mautic/app/console mautic:emails:send --env=prod >/dev/null 2>&1 | |
/usr/bin/php /var/www/mautic/app/console mautic:iplookup:download --env=prod >/dev/null 2>&1 | |
chown apache.apache /var/www/mautic/app/logs/* | |
fi | |
rm -f $LOCKFILE | |
# eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment