What cron jobs should be configured for Mautic 2.x

Based on the current documentation, the following cron jobs may need to be implemented.  

Important note: Where you see /path/to/php please replace with the path to PHP on your server - this is often in /usr/bin/php but if you have command line access you can type the following command:

which php

to find the location of PHP on your server.

Compulsory

Update segments

/path/to/php /path/to/mautic/app/console mautic:segments:update 

This cron job updates your segments based on your settings.  For example, if a user has completed a form, and as a result they get added to a segment.  

By default, the script will process contacts in batches of 300. If this is too many for your server's resources, use the option --batch-limit=X replacing X with the a number of contacts to process each batch.  For example to limit batch sizes to 150:

/path/to/php /path/to/mautic/app/console mautic:segments:update --batch-limit=150

You can also limit the number of contacts to process per script execution using --max-contacts to further limit resources used.  For example to limit the script to processing only 100 contacts per execution:

/path/to/php /path/to/mautic/app/console mautic:segments:update --max-contacts=100

Rebuild campaigns

/path/to/php /path/to/mautic/app/console mautic:campaigns:rebuild

This cron job rebuilds campaigns based on any actions which may have occurred, for example if a user has been added to a segment and then as a result will be added to a campaign.

By default, the script will process contacts in batches of 300. If this is too many for your server's resources, use the option --batch-limit=X replacing X with the a number of contacts to process each batch.

For example, to limit batch size to 150:

/path/to/php /path/to/mautic/app/console mautic:campaigns:rebuild --batch-limit=150

You can also limit the number of contacts to process per script execution using --max-contacts to further limit resources used.  For example, to limit the script to processing only 100 contacts per execution:

/path/to/php /path/to/mautic/app/console mautic:campaigns:rebuild --max-contacts=100

Trigger campaign events

path/to/php path/to/mautic/app/console mautic:campaigns:trigger

This cron job executes campaign actions based on your campaign workflows.  For example, if a campaign action of send email has been triggered by a lead's behaviour.

By default, the script will process events in batches of 100. If this is too many for your server's resources, use the option --batch-limit=X replacing X with the a number of events to process each batch.  For example, to limit the number of events to be processed in each batch to 150:

path/to/php path/to/mautic/app/console mautic:campaigns:trigger --batch-limit=150

You can also limit the number of contacts to process per script execution using --max-events to further limit resources used.  For example, to limit the script to executing only 100 events per execution:

path/to/php path/to/mautic/app/console mautic:campaigns:trigger --max-events=100

May be needed

Marketing messages

Emails that are marked as Marketing Messages (such as emails to be sent as part of a marketing campaign), will be inserted into a message queue if frequency rules are setup as either system-wide or per-contact.

To process this queue and reschedule sending these messages, this cron job should be added to your list of jobs:

path/to/php path/to/mautic/app/console mautic:messages:send

Important note: These messages will only be added to the queue only if frequency rules are applied either system-wide or per-contact.

Process email queue

If your system is set up to queue email rather than send immediately, you will need to add the following cron job to process the queue and send the emails:

path/to/php /path/to/mautic/app/console mautic:emails:send

Send scheduled emails

Since Mautic 2.2.0, you can use cron jobs to send scheduled broadcasts to specific channels.  To date the only way of using this is with emails, however in the future this could be expanded to include other channels.  The command can be used to send messages instead of waiting with the browser open while the broadcast is being processed.

Emails must be published and have a publish up date, which is an attempt to prevent unintentional email broadcasts, and it's important to remember that contacts will only receive the broadcast if they have not received it already.

Only enable this cron if you know you need to use it - if you don't know what it is, you probably won't need it :)

path/to/php /path/to/mautic/app/console mautic:broadcasts:send [--id=ID] [--channel=CHANNEL]

Fetch and process monitored email

If you are using Bounce Management, you will need the following cron job to fetch the bounced emails and process them:

path/to/php /path/to/mautic/app/console mautic:email:fetch

Social monitoring

If you are using the social media monitoring features, you will require the following cron job to identify the messages:

path/to/php /path/to/mautic/app/console mautic:social:monitoring

Webhooks

If you have configured Mautic to process webhooks in batches, you will require the following cron job:

path/to/php /path/to/mautic/app/console mautic:webhooks:process

Updating the MaxMind IP Lookup database

If you use the MaxMind IP Lookup database, you will need to run the following cron job - maybe monthly - to update the database:

path/to/php /path/to/mautic/app/console mautic:iplookup:download

Cleaning out old data

WARNING: this is a destructive process which will result in deletion of data

This script allows you to clean out old data - note that not all data can be purged with this script.  Currently supported are audit log entries, visitors (anonymous contacts), and visitor page hits. Use --dry-run to view the number of records to be purged before making any changes.  This will permanently delete data! Be sure to keep database backups.

path/to/php /path/to/mautic/app/console mautic:maintenance:cleanup --days-old=365 --dry-run

Integrations

Most of the Mautic integrations require a cron job to fire the synchronisation or actions.  Listed below are those we are aware of - please do add a comment if you wish your cron jobs to be listed below.

Citrix

path/to/php /path/to/mautic/app/console citrix:sync

Usage: citrix:sync [options]

Options:

-p, --product[=PRODUCT] Product to sync (webinar, meeting, training, assist)

-i, --id[=ID] The id of an individual registration to sync

Hubspot

To fetch and synchronise leads:

path/to/php /path/to/mautic/app/console mautic:integration:fetchleads --integration=Hubspot

To push lead activity:

path/to/php /path/to/mautic/app/console mautic:integration:pushleadactivity --integration=Hubspot

Salesforce

To pull records from the leads object in Salesforce:

path/to/php app/console mautic:integration:fetchleads --integration=Salesforce

To push lead activity:

path/to/php /path/to/mautic/app/console mautic:integration:pushleadactivity --integration=Salesforce

Options:

--time-interval Set the amount of time we want to consider. Possible entries: "10 days", "1 day", "10 minutes", "1 minute".

Important note: The maximum time interval that can be used for the Salesforce integration is 29 days.