Adjust cron jobs for Mautic... is it possible?
-
Tried to understand what is written in the linked post, but not sure I am following the necessity of what they mention there.
For refrence in Cloudron the contab for mautic is https://git.cloudron.io/cloudron/mautic-app/-/blob/master/crontab.system.template?ref_type=heads
-
Thanks for the feedback, will rework this article as the next step.
The reason why this initial Mautic Setup is not used by us and other Mautic Partners: The staggered setting of making sure that the commands run in the right sequence:
- 0,15,30,45 * * * * (echo "==> cron: mautic:segments:update"; sudo -E -u www-data php /app/code/bin/console mautic:segments:update) > /proc/$(cat /var/run/crond.pid)/fd/1 2>&1
- 5,20,35,50 * * * * (echo "==> cron: mautic:campaigns:update"; sudo -E -u www-data php /app/code/bin/console mautic:campaigns:update) > /proc/$(cat /var/run/crond.pid)/fd/1 2>&1
- 10,25,40,55 * * * * (echo "==> cron: mautic:campaigns:trigger"; sudo -E -u www-data php /app/code/bin/console mautic:campaigns:trigger) > /proc/$(cat /var/run/crond.pid)/fd/1 2>&1
With that setup, the Marketing Automation needs at average 12,5 minutes, before a client gets a response from the system. Thats no acceptable, as it negatively impacts response rates and conversion rates. Just imagine, you want to get some information, fill in a form and don't get a response in a timely manner.
We reworked the cronjob setup to concatenate those commands in a shell script and run it - depending on the server speed and the load - every 1-3 minutes.
/PATHTOPHP/php /PATHTOMAUTIC/app/console mautic:segments:update && /PATHTOPHP/php /PATHTOMAUTIC/app/console mautic:campaigns:update & /PATHTOPHP/php /PATHTOMAUTIC/app/console mautic:campaigns:trigger
So in order to achieve that, I need to be able to
- disable the default cloudron cronjobs for mautic (will it be persistent across updates?) and
- run a custom shell script containing those commands instead (will this shell script stay there across updates?).
Hope this clarifies the reason behind it.
-
I am no mautic expert, so I can't fully follow this requirement still. However, have you seen https://docs.cloudron.io/apps/mautic/#custom-cron-jobs for custom cron jobs with mautic?
Ideally if this is something all mautic users in the end need (hopefully other can contribute to the discussion here) I guess it would be better to adjust the package cron then.
-
You can edit the
/app/data/crontab.system
patterns as you wish . See https://docs.cloudron.io/apps/mautic/#system-cron-jobs . I agree that mautic's flow of calling cron for everything is suboptimial. This is why the package made the patterns editable . In fact, for processing any task, the mautic way is to run a cronjob manually. -
@girish said in Adjust cron jobs for Mautic... is it possible?:
You can edit the
/app/data/crontab.system
patterns as you wish . See https://docs.cloudron.io/apps/mautic/#system-cron-jobs . I agree that mautic's flow of calling cron for everything is suboptimial. This is why the package made the patterns editable . In fact, for processing any task, the mautic way is to run a cronjob manually.Will this file stay intact with every Mautic update via cloudron? Because I would then comment them out and completely replace them with custom cron jobs.
-
We have years long experience with mautic
Its important to help with a default cronjob setup. The one from the docs work, but its not optimal. I will help setting it up in a better way together with you, if you like.
For now it would be good, if the out of the box setup for cronjobs in cloudron could also be disabled. I did it by commenting out every line in the crontab.system - but will this be replaced again by an update or not? Its in the /app/data directory. So I think it will not?
I already changed my cronjob setup with a shell file. I trigger this every minute, in case its still running, it will be ignored. I will need to extend it by other optional cronjob tasks - maybe having even two or more scripts. One to run every minute (if server can handle it). And then some maintenance task that don't need to run that often.
#! /bin/sh # Variables phpinterpreter="php -d memory_limit=1G" pathtoconsole="../code/bin/console" lockfile="/tmp/cronjob.lock" # Locking mechanism if [ -f "$lockfile" ]; then echo "Script is already running." exit fi touch "$lockfile" # Function to execute commands execute_command() { $phpinterpreter $pathtoconsole $1 } # Execute commands execute_command "mautic:segments:update --batch-limit=900" \ && execute_command "mautic:campaigns:rebuild --batch-limit=300" \ && execute_command "mautic:campaigns:trigger" \ && execute_command "mautic:broadcasts:send --batch=800" \ && execute_command "mautic:emails:send --message-limit=790" \ && execute_command "mautic:unusedip:delete" \ && execute_command "mautic:import --limit=500" \ && execute_command "mautic:webhooks:process" \ && execute_command "mautic:reports:scheduler" # Unlock the script at the end rm -f "$lockfile"
Myself I'm not a script or Linux Professional. Probably that approach can be improved.
-
-