Segment email sent to same contacts multiple times

Your software
My Mautic version is: 5.1.1
My PHP version is: 8.2.24
My Database type and version is: 11.4.3 MariaDB

I am using Mautic to at the point exclusively send segment emails. I am using the etailors_amazon_ses plugin to send via SES. I am getting reports that recipients are receiving the same email 3-4 times on a send. Looking at the numbers for the email send in Mautic I see that 641 were sent, but in the SES dashboard I see 781 were sent.

i installed Mautic using the script from Mauteam. Sending email for our non-profit is only part of my job and so I don’t even remember why the email:send line is commented out as I set this all up a couple of months ago. While I normally would start troubleshooting and testing potential fixes, the only way to know if it is solved is to send out another email and so I would appreciate any help I can get on this one.

Here is the contents of my crontab file.

Watch out not to put nightly work during the day because of different timezones.

*/10 * * * * /var/www/html/var/lock/consume_mautic.sh >> /var/www/html/var/logs/mautic_consume.log 2>&1

Main cronjobs

0-59/3 * * * * sleep 0 && php /var/www/html/bin/console mautic:segments:update
1-59/3 * * * * sleep 0 && php /var/www/html/bin/console mautic:campaigns:update -n > /dev/null 2>> /var/log/cron/cron-error.log
2-59/5 * * * * sleep 0 && php /var/www/html/bin/console mautic:campaigns:trigger -n > /dev/null 2>> /var/log/cron/cron-error.log
#* * * * * sleep 0 && php /var/www/html/bin/console mautic:emails:send -n > /dev/null 2>> /var/log/cron/cron-error.log

          •    sleep 0 && php /var/www/html/bin/console mautic:webhooks:process -n > /dev/null 2>> /var/log/cron/cron-error.log
            

Old data cleanup

0 1 * * * sleep 0 && php /var/www/html/bin/console mautic:maintenance:cleanup -n --days-old=160 > /dev/null 2>> /var/log/cron/cron-error.log
30 1 * * * sleep 0 && php /var/www/html/bin/console mautic:unusedip:delete -n -l 1000000 > /dev/null 2>> /var/log/cron/cron-error.log

Imports and reports

0 2 * * * sleep 0 && php /var/www/html/bin/console mautic:import > /dev/null 2>> /var/log/cron/cron-error.log
0 3 * * * sleep 0 && php /var/www/html/bin/console mautic:reports:scheduler > /dev/null 2>> /var/log/cron/cron-error.log

Maxmind IP Lookup

0 4 * * * sleep 0 && php /var/www/html/bin/console mautic:iplookup:download -n > /dev/null 2>> /var/log/cron/cron-error.log
30 4 * * * sleep 0 && php /var/www/html/bin/console mautic:donotsell:download -n > /dev/null 2>> /var/log/cron/cron-error.log
0 5 * * * sleep 0 && php /var/www/html/bin/console mautic:max-mind:purge -n > /dev/null 2>> /var/log/cron/cron-error.log

Hello, what does this really do?

*/10 * * * * /var/www/html/var/lock/consume_mautic.sh

Can you share the script? Is it possible that you run the consume script concurrently?

I honestly don’t know if I am running the script concurrently or not. Do you know where I should check to see if that would be happening and how I would go about correcting that?

Here is the script. I modeled it from here. Configuring Doctrine for Email Queue Management in Mautic with Cron Jobs - Mautic Knowledgebase

# Check if the lock file exists

# Path to the lock file
LOCKFILE="/var/www/html/var/lock/consume_mautic.lock"
LOGFILE="/var/www/html/var/logs/mautic_consume_detailed.log"

# Define the lock file timeout (9 minutes = 540 seconds)
LOCKFILE_TIMEOUT=540

# Function to log messages
log() {
    echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOGFILE"
}

log "Script started."

# Check if the lock file exists
if [ -e $LOCKFILE ]; then
    LOCKFILE_AGE=$(($(date +%s) - $(stat -c %Y $LOCKFILE)))
    if [ $LOCKFILE_AGE -ge $LOCKFILE_TIMEOUT ]; then
        log "Lock file is older than $LOCKFILE_TIMEOUT seconds. Removing stale lock file."
        rm -f $LOCKFILE
    else
        log "Process is already running. Exiting."
        exit 1
    fi
fi

# Create the lock file
touch $LOCKFILE
log "Lock file created."

# Run the messenger:consume command for emails with increased verbosity and log the output
log "Starting to consume messages..."
/usr/bin/php /var/www/html/bin/console messenger:consume email --limit=40 --time-limit=480 --memory-limit=128M -vvv >> >

log "Finished consuming messages."

# Remove the lock file when done
rm -f $LOCKFILE
log "Lock file removed."

log "Script finished."