Filter applied to Segments, but contacts are not getting linked to the segment

My Mautic version is: 4.0.0
My PHP version is: PHP Version 7.4.33
My Database type and version is: MariaDB (10.6.12-MariaDB-0ubuntu0.22.04.1)

Your problem
My problem is:

  1. I added two contacts manually. I added tags to both contact.
  2. Then I created a new Segment and added a filter for the Tag values I just assigned to the contacts.
  3. After that, I was expecting the two contacts to be linked to the segment, but the segment still says “No contacts”

What can I do to fix this? I am just staring off with Mautic and this is just Day-1 for me :slight_smile:
I read somewhere that I may need to run cron job of some sort, but I could not find the information for it.

I am running Mautic on AWS EC2, so any related guidance would be greatly appreciated.

Based on your other post you probably figured out, that your cronjobs are not running.
Do you have an ssh access to your server?

Hi @joeyk
Thanks for your reply.
Yes I have SSH access.
I also added the cron job to the server like this:
* * * * * /usr/local/bin/php /var/www/html/mautic/bin/console mautic:segments:update —env=prod > /dev/null 2>&1

When I do crontab -l I can see this line of code. But still the segment is not getting updated with tagged contacts.

Can you run this code in the ssh console without the

/dev/null 2>&1

ending and see the result

Just tried that too.
Still its not working :frowning:
Everything else is working fine on Mautic installation.

could you plz share the result what you recieve back in command line?
Also: you said everything else is working.
Does campaign triggering working?

Hi, Did you mean running this code directly in SSH?
I just did that.
I get command not found.

This is what I ran:

* * * * * /usr/local/bin/php /var/www/html/mautic/bin/console mautic:segments:update

Oh Sorry my mistake,
I ran this script

/var/www/html/mautic/bin/console mautic:segments:update

and got this result:

1 total contact(s) to be added in batches of 300
 1/1 [============================] 100%
0 total contact(s) to be removed in batches of 300
1 contact(s) affected

The script ran successfully and updated the segment with a contact that was tagged.

So looks like if I execute through SSH, its working. Somehow the cron job is not executing on its own.

Dont run the stars in your command line. That is for the crontab.
Run this:

/usr/local/bin/php /var/www/html/mautic/bin/console mautic:segments:update


php /var/www/html/mautic/bin/console mautic:segments:update

Ok, So I tried the following:

/usr/local/bin/php /var/www/html/mautic/bin/console mautic:segments:update

No such file or directory

php /var/www/html/mautic/bin/console mautic:segments:update

Executed successfully.

So I did crontab -e
Edited my cron job string to the one above that worked.
SSH said: “crontab: installing new crontab”
I waited a few minutes and checked, but the segment was not updated :frowning:

Not sure what I am doing wrong here…

Ok looks like it is working now.
Thanks a lot for brainstorming this with me :slight_smile:
Only problem I noticed is that once the script runs and it adds a contact to the segment and later if I remove the contact from segment manually, it does not add that contact again.

Not sure how to solve that :slight_smile:

1 Like

This is how it should work.
Once a contact is manually removed (you must have a reason to do so), it will be immune to the segment filters. This is your own protection not to create infinate loops and crash your own server.

Thanks a lot for your explanation. Really appreciate your help :slight_smile:

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.