Workflow not working with date/time as conditions

I have created a workflow that will send an email to the person to whom task is assigned, on a date/time that was set in the task in the field called ‘Warning time’ - attached workflow_01.

The email will be sent when the warning = today - attached workflow_02

This does not work so I an email by using 'Only On Save" so that I can see the values of the variables in the workflow - attached workflow_03. The result is in attached workflow_04.

My server time - attached workflow_05.

It appears that the workflow module is using UTC. This causes the times to differ by two hours.

How can I resolve this?

My setup is as follow: SuiteCRM Version 7.10.7 Sugar Version 6.5.25 (Build 344)

My server: Debian 9.5 PHP version 7.2.8

Your workflows are launched from CLI PHP when they are not “on save”. This uses a different php.ini

You can find it from the command-line with

php -i | grep php.ini

And check your effective value with

php -i | grep timezone

Hi pgr

Thank you for your reply.

These are the results:

root@crm:~# php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php/7.2/cli
Loaded Configuration File => /etc/php/7.2/cli/php.ini

root@crm:~# php -i | grep timezone
Default timezone => Africa/Johannesburg
date.timezone => Africa/Johannesburg => Africa/Johannesburg

That looks right, does it not?

Yes that looks fine.

Please try some time-based workflow that uses a normal, existing field, instead of your custom “warning time” field. This will let you determine if the problem is when saving your field, or if it is a problem for all workflows in your system.

Oh, and another thing: in Admin /Schedulers, when you enter the Workflow Job, do you see a “last ran successfully” time that is recent, and in the correct timezone?

Hi pgr

Thanks for the reply.

So I ran the query on the due date. Same result. The workflow does not fire at all. If I then fire it by using the ‘Only on Save’, it does execute and the variables that is sent with the email, indicates the two hour time difference between the task and the workflow.

It appears that the workflow uses UTC0 against my timezone which is equal to UTC+2.

How would one resolve this?

“On save” workflows are triggered from the web app, and use the web server’s version of PHP. The rest of the Workflows are triggered by the cron jobs, and might use a different CLI PHP. So it is common to see different timezones between these cases, when things haven’t been properly configured yet.

What I don’t understand is how the timezone seems to be set correctly in your CLI PHP and still doesn’t play well with the Workflows.

How exactly are you launching your cron jobs? Which user’s crontab are you using?

You can check with

crontab -l -u root
crontab -l -u www-data
crontab -l -u apache
crontab -l -u your-personal-user

Which one is launching cron.php?

Hi pgr

Thanks for taking the time to answer me.

My cron.php is launched from : crontab -l -u www-data

Ok, and what is your exact command there?

I am trying to figure out precisely which PHP executable is running, to see if it might be different from the one you queried above with “php -i”.

We can try specifying a full PHP path in your crontab command, and we can even pass it a timezone from the command-line if necessary.

Hi pgr

Once again thanks for replying.

          • www-data cd /var/www/html/crm; php -f cron.php > /dev/null 2>&1

I think when you’re using a specific user’s crontab, you don’t include the user name. So this would work in the system-wide crontab (“crontab -e” or “nano /etc/crontab”)

* * * * * www-data cd /var/www/html/crm; php -f cron.php > /dev/null 2>&1 

But it wouldn’t work in the user’s crontab (“crontab -e -u www-data”), where you should put only this:

* * * * * cd /var/www/html/crm; php -f cron.php > /dev/null 2>&1 

Have you tried changing the condition in your worflow using “Less Than or Equal” instead of “Equal”?

Hi pgr

Thanks for replying. I have actually tried it both ways with no success.

Hi amariussi

Thanks for replying. Yes I have also done that with no luck.

What about typing this in your Linux?


Is your operating system on the correct timezone?

Finally, try this to find out your php executable

which php

And use that full path in cron, something like:

* * * * * cd /var/www/html/crm; /usr/bin/php -f cron.php > /dev/null 2>&1

If that is still no good, try giving it the timezone via the command line:

* * * * * cd /var/www/html/crm; /usr/bin/php -d date.timezone="Europe/Lisbon" -f cron.php > /dev/null 2>&1

Hi pgr

Thanks for the info.

root@crm:~# date
Mon Aug 27 21:44:30 SAST 2018

root@crm:~# which php

I tried * * * * * cd /var/www/html/crm; /usr/bin/php -f cron.php > /dev/null 2>&1 with no luck

I then tried * * * * * cd /var/www/html/crm; /usr/bin/php -d date.timezone=“Africa/Johannesburg” -f cron.php > /dev/null 2>&1 and still no luck

What do you mean “no luck”?

In Admin /Schedulers, when you enter the Workflow Job, do you see a “last ran successfully” time that is recent, and in the correct timezone?

If so, then the cron set up is correct, only the individual Workflow conditions might be wrong. If not, the cron set up is broken, but I am running out of suggestions to get that right :frowning:

Hi pgr

Once again thanks for your assistance.

It seems like the cron job is working. (see attached)

It is the individual workflow that is not working …


Please post a screenshot of the workflow logic as well as of the custom fields you have creted,