Skip to content

Instantly share code, notes, and snippets.

@kgroveshok
Created July 4, 2017 19:31
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 kgroveshok/c95a40ed016a4e9dcb208494e62f852d to your computer and use it in GitHub Desktop.
Save kgroveshok/c95a40ed016a4e9dcb208494e62f852d to your computer and use it in GitHub Desktop.
Prevent Mautic crons from clashing with one another
#!/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