Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.