Segment Update Cron Jobs Configuration

I have written many times on this subject and find myself running into a re-occuring problem inside Mautic and how cronjob are fired off using the console.

In console mautic:segments:update there is a flag -i which lets you choose which segment ID you would like to update. This is all great and helps a fortune, however the fundamental problem here is that we want many of our segments to be updated every minute, and some of them to be updated less often.

Why ? Because this is killing CPU usage by MySQL.

Would it not be great to have a flag like -vi or -v -i that would exclude certain segment ID’s.

Yes there are workarounds and you can go and setup many cronjob for specific segments, the problem is that after you have done this and go add a new segment, then you need to go and update your cronjob with this new segment id. This can become very problematic when dealing with hundred of clients.

Main problem is that if you have a cronjob that is running every minute on all segments it will still run all your segments

A video is coming up regarding this.
I’ll post it here once it’s done.
Joey

Hey mate

Did you write up anything on this mate - cannot for the life of me find anything online.

I remember a while back a mautic plugin that allowed you to update a segment within the UI, and I feel this was extended to the cli params.

Closest I have found is is the old segment extras plugin (5yrs old)

Business case I am running

  • got a 250k db with prob 40 dynamic segments
  • I manage all campaigns from dynamic segments
  • new enquiry is submitted, we refresh the segments, update campaigns, trigger campaigns.

Ideally would love to call 1 specific segment and 1 campaign so I am not refreshing the full db.

mysql CPU is hating life as it gets smashed
Going to get more complex as we now want to run segments from custom objects against linked contacts and looking at nested queries.

Well I feel this is not documented haha

mautic:segment:update -i 22
so -i and the segment ID

guess this will work for campaign update and trigger aswell

Hey @tornmarketing

Correct -i will work for both segments, campaigs update/trigger.

There have been some plugins I have seen in the past for updating via the GUI as well as some nice initiatives like Joeys newcron.sh which looks for the name of the segment and extracts the parameters and updates.

I actually used a plugin I think you developed CustomNavLinks, where I created a workflow inside my self hosted n8n to capture a Webhooks, inside Mautic I created a form asking which component you want to update (Segment/Campaign) and All/Specific ID, then put this form in a LP inside Mautic and added this as an iframe and menu item with Navlinks :slight_smile: when triggered sends off a Webhooks to n8n which takes care of running the respective command.

There is also an interesting talk on replacing cronjob with system tasks in Linux: Mautic Cron jobs for 2022 - Klemen KobetiÄŤ - YouTube

1 Like

Yes, here is the video:

3 Likes