Mautic Community Forums

Cron Jobs - what's the difference?

Hello,

the Mautic cron job page - https://www.mautic.org/docs/en/setup/cron_jobs.html - is mentioning 3 different campaign-related cron jobs:

  1. campaigns: trigger
  2. campaigns:rebuild
  3. campaigns:update

What is the difference between them?
Do I need all of them if I’d like to run a campaign (e.g. a simple newsletter campaign)?

Thank you for your help.

Regards, Arne

This is output from running the :penguin: command line tool console (or sudo -Hu www-data php app/console if you want to get picky) in the top-level :m: Mautic directory.

$ console
Mautic version 2.15.1 - app/prod

Usage:
  command [options] [arguments]

Available commands:
  help                              Displays help for a command
  list                              Lists commands
...
mautic
  mautic:segments:rebuild           Update contacts in smart segments based on new contact data.
  mautic:segments:update            Update contacts in smart segments based on new contact data.
  mautic:campaigns:messagequeue     Process sending of messages queue.
  mautic:campaigns:messages         Process sending of messages queue.
  mautic:campaigns:rebuild          Rebuild campaigns based on contact segments.
  mautic:campaigns:trigger          Trigger timed events for published campaigns.
  mautic:campaigns:update           Rebuild campaigns based on contact segments.

Notice that some of the commands have the same description?

:mag: Let’s look at the usage information for the campaign update:

$ console mautic:campaigns:update --help
Usage:
  mautic:campaigns:rebuild [options]
  mautic:campaigns:update
Options:
...
Help:
  Rebuild campaigns based on contact segments.

mautic:campaigns:rebuild and mautic:campaigns:update are the same command.
One is an alias for the other.

:clipboard: The minimum list commands you want to be running every :clock10: 10 or 15 minutes in cron are:

mautic:segments:update
mautic:campaigns:trigger  
mautic:campaigns:update

:bulb: ProTip

When running these commands interactively, you can shorten them to m:s:u for segment update and m:c:t for campaign trigger. c:c works for cache:clear too.

I hope that helps you out.

Virgil

1 Like

This thread was listed in The Unofficial Mautic Newsletter, so I thought I’d extend it some more.

Mautic Cron jobs

metadata tag: #support

:clipboard: The minimum list of commands you need to run every :clock10: 10 or 15 minutes is:

mautic:segments:update
mautic:campaigns:trigger  
mautic:campaigns:update

Self-hosted Mautic cron jobs

These are the commands I run, for every deployed :m: instance.

:information_source: Note

metadata tag: #3rd-party-addons

cronjob summary

My cron jobs

These are the commands I run, for every deployed :m: instance.

:clock3: Commands to run every 15 minutes

*/15 * * * *

:scroll: SEGMENTS

Update segment membership for contacts

mautic:segments:update --batch-limit=500

:mountain_railway: CAMPAIGNS

Add contacts to campaigns

mautic:campaigns:update

Execute campaign decisions and events

mautic:campaigns:trigger

:email: EMAIL

Send the scheduled broadcast messages

  • these emails are not part of a campaign and may have a date / time to start sending.

mautic:broadcasts:send

Send queued messages

:bulb: ProTip

When a marketing campaign email is triggered, or a broadcast (segment) email is sent, and a contact has a defined frequency rule, email can still be queued.

mautic:messages:send

Process mailer queue

:heavy_multiplication_x:mautic:emails:send

  • :mage: My email is configured to :email:Send immediately
    Mautic is not set to queue email.

Download email and perform bounce management

:heavy_multiplication_x:mautic:emails:fetch

  • :mage: My bounce management is configured for AWS SES (using AWS SNS)
    Do not need mailbox monitoring.

:gear: INTEGRATIONS

Do things with a CRM

mautic:integration:fetchleads --integration=INTEGRATION
mautic:integration:pushleadactivity --integration=INTEGRATION

  • :mage: Not integrated with a CRM

:wrench: WEBHOOKS

Process webhooks

mautic:webhooks:process

:spider_web: SOCIAL MEDIA

Find tweets about #mautibot

mautic:social:monitoring

:busts_in_silhouette: CONTACTS

Import CSV files in the background

mautic:import --no-interaction

Custom Import plugin

  • Import multiple contact CSV files in the background
  • metadata tag: #3rd-party-addons

mautic:import:parallel --no-interaction

Do Not Contact Extras plugin

mautic:dnc:import --no-interaction

:calendar: Commands to run daily

Runs between midnight and 3 am
@daily

:clipboard: MAINTENANCE

Remove log entries, IP data, user notifications, visit history from anonymous leads

mautic:maintenance:cleanup --days-old=365 --no-interaction

Remove stale user notifications

mautic:notifications:purge --no-interaction

:scroll: REPORTS

Generate and send scheduled reports

mautic:reports:scheduler

:calendar: Commands to run monthly

Runs between midnight and 3 am, on the first Wednesday of the month
:mage: I’m ten hours ahead of UTC (TZ=Australia/Brisbane), so run on Wednesday

:safety_pin: METADATA

:mag: GeoIP data update

MaxMind updates their database the first Tuesday of the month

mautic:iplookup:download

:dolphin: DATABASE SCHEMA

View the status of a schema mappings

doctrine:migrations:status

Check the schema mappings

doctrine:schema:validate

Report SQL statements to update database schema to current metadata

doctrine:schema:update --dump-sql

:busts_in_silhouette: CONTACTS

:abcd: Visitor IP data

Delete IP addresses that are not used in any other database table

mautic:unusedip:delete

Remove duplicates

mautic:contacts:deduplicate


end of cronjobs

References

Check out these posts for more information:

:mag_right: console commands in more detail

This is output from the :keyboard: command-line tool console.

:bulb: ProTip

Actually I use a :penguin: shell alias that executes the console command as the same user as the webserver.
Add this to your login profile: (usually $HOME/.bashrc)

  • alias console='sudo -Hu www-data php app/console'
Mautic console commands
 Mautic version 2.15.2 - app/prod
  cache:clear                                       Clears the cache
  cache:warmup                                      Warms up an empty cache
  mautic:assets:generate                            Combines and minifies asset files from each bundle into single production files
  mautic:broadcasts:send                            Process contacts pending to receive a channel broadcast.
  mautic:campaigns:execute                          Execute specific scheduled events.
  mautic:campaigns:messagequeue                     Process sending of messages queue.
  mautic:campaigns:messages                         Process sending of messages queue.
  mautic:campaigns:rebuild                          Rebuild campaigns based on contact segments.
  mautic:campaigns:trigger                          Trigger timed events for published campaigns.
  mautic:campaigns:update                           Rebuild campaigns based on contact segments.
  mautic:campaigns:validate                         Validate if a contact has been inactive for a decision and execute events if so.
  mautic:citrix:sync                                Synchronizes registrant information from Citrix products
  mautic:contacts:deduplicate                       Merge contacts based on same unique identifiers
  mautic:dnc:import                                 Imports custom dnc data to Mautic
  mautic:email:fetch                                Fetch and process monitored email.
  mautic:emails:fetch                               Fetch and process monitored email.
  mautic:emails:send                                Processes SwiftMails mail queue
  mautic:import                                     Imports data to Mautic
  mautic:import:directory                           Import CSV files from directory
  mautic:import:parallel                            Parallel import for Mautic
  mautic:install:data                               Installs Mautic with sample data
  mautic:integration:fetchleads                     Fetch leads from integration.
  mautic:integration:pipedrive:fetch                Pulls the data from Pipedrive and sends it to Mautic
  mautic:integration:pipedrive:push                 Pushes the data from Mautic to Pipedrive
  mautic:integration:pushactivity                   Push lead activity to integration.
  mautic:integration:pushleadactivity               Push lead activity to integration.
  mautic:integration:synccontacts                   Fetch leads from integration.
  mautic:iplookup:download                          Fetch remote datastores for IP lookup services that leverage local lookups
  mautic:maintenance:cleanup                        Updates the Mautic application
  mautic:messages:send                              Process sending of messages queue.
  mautic:migrations:generate                        Generate a blank migration class.
  mautic:plugins:install                            Installs, updates, enable and/or disable plugins.
  mautic:plugins:reload                             Installs, updates, enable and/or disable plugins.
  mautic:plugins:update                             Installs, updates, enable and/or disable plugins.
  mautic:queue:process                              Process queues
  mautic:remove:tags                                Remove tags from contacts
  mautic:reports:scheduler                          Processes scheduler for reports export
  mautic:segments:check-builders                    Compare output of query builders for given segments
  mautic:segments:rebuild                           Update contacts in smart segments based on new contact data.
  mautic:segments:update                            Update contacts in smart segments based on new contact data.
  mautic:social:monitoring                          Looks at the records of monitors and iterates through them.
  mautic:theme:json-config                          Converts theme config to JSON from PHP
  mautic:transifex:pull                             Fetches translations for Mautic from Transifex
  mautic:transifex:push                             Pushes Mautic translation resources to Transifex
  mautic:translation:createconfig                   Create config.php files for translations
  mautic:translation:debug                          Displays translation messages informations
  mautic:unusedip:delete                            Deletes IP addresses that are not used in any other database table
  mautic:update:apply                               Updates the Mautic application
  mautic:update:find                                Fetches updates for Mautic
  mautic:webhooks:process                           Process queued webhook payloads

:bulb: ProTip

When running these commands interactively :keyboard: , you can shorten them to console m:s:u for segment update and console m:c:t for campaign trigger.
console c:c works for cache:clear too.

aliases

Notice that some of the commands have the same description?

:mag: Let’s look at the usage information for the campaign update command:

$ console mautic:campaigns:update --help
Usage:
  mautic:campaigns:rebuild [options]
  mautic:campaigns:update
Options:
...
Help:
  Rebuild campaigns based on contact segments.

mautic:campaigns:rebuild and mautic:campaigns:update are the same command.

update is just an alias for rebuild.

:m: Mautic command aliases

Here is the list of :m: Mautic commands :keyboard: with their aliases:

I’ve used the :mage: to mark my suggestions on which command or alias I prefer to use for consistency.

  • mautic:messages:send :mage:
    • mautic:campaigns:messages
    • mautic:campaigns:messagequeue
  • mautic:campaigns:rebuild
    • mautic:campaigns:update :mage:
  • mautic:email:fetch
    • mautic:emails:fetch :mage:
  • mautic:emails:send :mage:
    • internally calls swiftmailer:spool:send
  • mautic:integration:fetchleads
    • mautic:integration:synccontacts :mage:
  • mautic:integration:pushleadactivity
    • mautic:integration:pushactivity :mage:
  • mautic:plugins:reload
    • mautic:plugins:install
    • mautic:plugins:update :mage:
  • mautic:segments:update :mage:
    • mautic:segments:rebuild
  • mautic:social:monitoring :mage:
    • internally calls: social:monitor:twitter:hashtags
    • internally calls: social:monitor:twitter:mentions

Symfony-framework aliases

Other commands from the Symfony framework with aliases:

  • debug:config
    • config:debug
  • debug:container
    • container:debug
  • debug:router
    • router:debug
  • debug:swiftmailer
    • swiftmailer:debug
  • debug:translation
    • translation:debug
  • debug:twig
    • twig:debug
  • lint:yaml
    • yaml:lint

Complete list

:information_source: Note

This includes commands from

  • :m: Mautic standard /app/bundles (eg mautic:segments:update)
  • :m: Mautic standard /plugins (eg mautic:citrix:sync)
  • community /plugins (eg mautic:integration:*)
  • GitHub Pull Requests (eg mautic:campaign:summarize).
  • Symfony framework /vendor (eg doctrine:*:*)

metadata tag: #3rd-party-addons

Available commands:

$ console list
Mautic version 2.15.2 - app/prod
Usage:
Usage:
  command [options] [arguments]

Options:
  -h, --help               Display this help message
  -q, --quiet              Do not output any message
  -V, --version            Display this application version
      --ansi               Force ANSI output
      --no-ansi            Disable ANSI output
  -n, --no-interaction     Do not ask any interactive question
  -s, --shell              Launch the shell.
      --process-isolation  Launch commands from shell as a separate process.
  -e, --env=ENV            The Environment name. [default: "prod"]
      --no-debug           Switches off debug mode.
  -v|vv|vvv, --verbose     Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
Available commands:
  help                                              Displays help for a command
  list                                              Lists commands
 assets
  assets:install                                    Installs bundles web assets under a public web directory
 bazinga
  bazinga:oauth-server:clean                        Clean expired tokens
 cache
  cache:clear                                       Clears the cache
  cache:warmup                                      Warms up an empty cache
 config
  config:debug                                      Dumps the current configuration for an extension
  config:dump-reference                             Dumps the default configuration for an extension
 container
  container:debug                                   Displays current services for an application
 debug
  debug:config                                      Dumps the current configuration for an extension
  debug:container                                   Displays current services for an application
  debug:event-dispatcher                            Displays configured listeners for an application
  debug:router                                      Displays current routes for an application
  debug:swiftmailer                                 Displays current mailers for an application
  debug:translation                                 Displays translation messages information
  debug:twig                                        Shows a list of twig functions, filters, globals and tests
 doctrine
  doctrine:cache:clear                              Flush a given cache
  doctrine:cache:clear-collection-region            Clear a second-level cache collection region.
  doctrine:cache:clear-entity-region                Clear a second-level cache entity region.
  doctrine:cache:clear-metadata                     Clears all metadata cache for an entity manager
  doctrine:cache:clear-query                        Clears all query cache for an entity manager
  doctrine:cache:clear-query-region                 Clear a second-level cache query region.
  doctrine:cache:clear-result                       Clears result cache for an entity manager
  doctrine:cache:contains                           Check if a cache entry exists
  doctrine:cache:delete                             Delete a cache entry
  doctrine:cache:flush                              Flush a given cache
  doctrine:cache:stats                              Get stats on a given cache provider
  doctrine:database:create                          Creates the configured database
  doctrine:database:drop                            Drops the configured database
  doctrine:database:import                          Import SQL file(s) directly to Database.
  doctrine:ensure-production-settings               Verify that Doctrine is properly configured for a production environment.
  doctrine:fixtures:load                            Load data fixtures to your database.
  doctrine:generate:entities                        Generates entity classes and method stubs from your mapping information
  doctrine:mapping:convert                          Convert mapping information between supported formats.
  doctrine:mapping:import                           Imports mapping information from an existing database
  doctrine:mapping:info
  doctrine:migrations:diff                          Generate a migration by comparing your current database to your mapping information.
  doctrine:migrations:execute                       Execute a single migration version up or down manually.
  doctrine:migrations:generate                      Generate a blank migration class.
  doctrine:migrations:latest                        Outputs the latest version number
  doctrine:migrations:migrate                       Execute a migration to a specified version or the latest available version.
  doctrine:migrations:status                        View the status of a set of migrations.
  doctrine:migrations:version                       Manually add and delete migration versions from the version table.
  doctrine:query:dql                                Executes arbitrary DQL directly from the command line.
  doctrine:query:sql                                Executes arbitrary SQL directly from the command line.
  doctrine:schema:create                            Executes (or dumps) the SQL needed to generate the database schema
  doctrine:schema:drop                              Executes (or dumps) the SQL needed to drop the current database schema
  doctrine:schema:update                            Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata.
  doctrine:schema:validate                          Validate the mapping files.
 fos
  fos:oauth-server:clean                            Clean expired tokens
 generate
  generate:doctrine:entities                        Generates entity classes and method stubs from your mapping information
 leezy
  leezy:pheanstalk:delete-job                       Delete the specified job if it exists.
  leezy:pheanstalk:flush-tube                       Delete all job in a specific tube.
  leezy:pheanstalk:kick                             Kick buried jobs from a specific tube.
  leezy:pheanstalk:kick-job                         Kick the specified job if it has a valid buried status, regardless of what tube it is in.
  leezy:pheanstalk:list-tube                        The names of all tubes on the server.
  leezy:pheanstalk:next-ready                       Gives the next ready job from a specified tube.
  leezy:pheanstalk:pause-tube                       Temporarily prevent jobs being reserved from the given tube.
  leezy:pheanstalk:peek                             Inspect a job in the system, regardless of what tube it is in.
  leezy:pheanstalk:peek-tube                        Take a peek at the first job in a tube, ready or burried.
  leezy:pheanstalk:put                              Puts a job on the queue.
  leezy:pheanstalk:stats                            Gives statistical information about the beanstalkd system as a whole.
  leezy:pheanstalk:stats-job                        Gives statistical information about the specified job if it exists.
  leezy:pheanstalk:stats-tube                       Gives statistical information about a specified tube, or about all tubes.
 lint
  lint:twig                                         Lints a template and outputs encountered errors
  lint:yaml                                         Lints a file and outputs encountered errors
 mautic
  mautic:assets:generate                            Combines and minifies asset files from each bundle into single production files
  mautic:broadcasts:send                            Process contacts pending to receive a channel broadcast.
  mautic:campaigns:execute                          Execute specific scheduled events.
  mautic:campaigns:messagequeue                     Process sending of messages queue.
  mautic:campaigns:messages                         Process sending of messages queue.
  mautic:campaigns:rebuild                          Rebuild campaigns based on contact segments.
  mautic:campaigns:summarize                        Builds historical campaign summary statistics if they do not already exist.
  mautic:campaigns:trigger                          Trigger timed events for published campaigns.
  mautic:campaigns:update                           Rebuild campaigns based on contact segments.
  mautic:campaigns:validate                         Validate if a contact has been inactive for a decision and execute events if so.
  mautic:citrix:sync                                Synchronizes registrant information from Citrix products
  mautic:contacts:deduplicate                       Merge contacts based on same unique identifiers
  mautic:dashboard:warm                             Warm the dashboard widget caches.
  mautic:dnc:import                                 Imports custom dnc data to Mautic
  mautic:email:fetch                                Fetch and process monitored email.
  mautic:emails:fetch                               Fetch and process monitored email.
  mautic:emails:send                                Processes SwiftMails mail queue
  mautic:import                                     Imports data to Mautic
  mautic:import:directory                           Import CSV files from directory
  mautic:import:parallel                            Parallel import for Mautic
  mautic:install:data                               Installs Mautic with sample data
  mautic:integration:enhancer:enhance               Runs one or more enhancers on leads.
  mautic:integration:enhancer:installcspcdata       Imports postal code, city, state, county, latitude, longitude and country
  mautic:integration:enhancer:installgendernames    Imports the SSA historic top 1000 names for genders
  mautic:integration:enhancer:trustedform           Claims Trustedform certificates offline.
  mautic:integration:enhancer:updatecorrectaddress  Installs the latest data files available from Expirian
  mautic:integration:fetchleads                     Fetch leads from integration.
  mautic:integration:pipedrive:fetch                Pulls the data from Pipedrive and sends it to Mautic
  mautic:integration:pipedrive:push                 Pushes the data from Mautic to Pipedrive
  mautic:integration:pushactivity                   Push lead activity to integration.
  mautic:integration:pushleadactivity               Push lead activity to integration.
  mautic:integration:synccontacts                   Fetch leads from integration.
  mautic:iplookup:download                          Fetch remote datastores for IP lookup services that leverage local lookups
  mautic:maintenance:cleanup                        Updates the Mautic application
  mautic:messages:send                              Process sending of messages queue.
  mautic:migrations:generate                        Generate a blank migration class.
  mautic:notifications:purge                        Purge stale users notfications.
  mautic:plugins:install                            Installs, updates, enable and/or disable plugins.
  mautic:plugins:reload                             Installs, updates, enable and/or disable plugins.
  mautic:plugins:update                             Installs, updates, enable and/or disable plugins.
  mautic:queue:process                              Process queues
  mautic:remove:tags                                Remove tags from contacts
  mautic:reports:scheduler                          Processes scheduler for reports export
  mautic:segments:check-builders                    Compare output of query builders for given segments
  mautic:segments:rebuild                           Update contacts in smart segments based on new contact data.
  mautic:segments:update                            Update contacts in smart segments based on new contact data.
  mautic:social:monitoring                          Looks at the records of monitors and iterates through them.
  mautic:theme:json-config                          Converts theme config to JSON from PHP
  mautic:transifex:pull                             Fetches translations for Mautic from Transifex
  mautic:transifex:push                             Pushes Mautic translation resources to Transifex
  mautic:translation:createconfig                   Create config.php files for translations
  mautic:translation:debug                          Displays translation messages informations
  mautic:unusedip:delete                            Deletes IP addresses that are not used in any other database table
  mautic:update:apply                               Updates the Mautic application
  mautic:update:find                                Fetches updates for Mautic
  mautic:webhooks:process                           Process queued webhook payloads
oneup
  oneup:uploader:clear-chunks                       Clear chunks according to the max-age you defined in your configuration.
  oneup:uploader:clear-orphans                      Clear orphaned uploads according to the max-age you defined in your configuration.
 orm
  orm:convert:mapping                               Convert mapping information between supported formats.
 rabbitmq
  rabbitmq:anon-consumer                            Executes an anonymous consumer
  rabbitmq:batch:consumer                           Executes a Batch Consumer
  rabbitmq:consumer                                 Executes a consumer
  rabbitmq:delete                                   Delete a consumers queue
  rabbitmq:dynamic-consumer                         Executes context-aware consumer
  rabbitmq:multiple-consumer                        Executes a consumer that uses multiple queues
  rabbitmq:purge                                    Purge a consumers queue
  rabbitmq:rpc-server                               Start an RPC server
  rabbitmq:setup-fabric                             Sets up the Rabbit MQ fabric
  rabbitmq:stdin-producer                           Executes a producer that reads data from STDIN
 router
  router:debug                                      Displays current routes for an application
  router:dump-apache                                [DEPRECATED] Dumps all routes as Apache rewrite rules
  router:match                                      Helps debug routes by simulating a path info match
 security
  security:encode-password                          Encodes a password.
 server
  server:run                                        Runs PHP built-in web server
  server:start                                      Starts PHP built-in web server in the background
  server:status                                     Outputs the status of the built-in web server for the given address
  server:stop                                       Stops PHPs built-in web server that was started with the server:start command
 social
  social:monitor:twitter:hashtags                   Looks at our monitoring records and finds hashtags
  social:monitor:twitter:mentions                   Searches for mentioned tweets
 swiftmailer
  swiftmailer:debug                                 Displays current mailers for an application
  swiftmailer:email:send                            Send simple email message
  swiftmailer:spool:send                            Sends emails from the spool
 translation
  translation:debug                                 Displays translation messages information
  translation:update                                Updates the translation file
 twig
  twig:debug                                        Shows a list of twig functions, filters, globals and tests
 yaml
  yaml:lint                                         Lints a file and outputs encountered errors

I hope this is useful to someone.

Virgil
:australia:

3 Likes

Thanks for the detailed post @virgilwashere - would you be interested in contributing some of this to the main documentation on cron jobs? It would definitely benefit from some TLC!

Thank you @virgilwashere for listing those resources.
The 2 posts on my blog are getting a little bit dated and I am looking forward for critical reviews in order to improve them, every input counts, so please feel free to add critical comments.


1 Like