Suitecrm: Schedulers configured to run every few minutes run every minute

Created on 9 Feb 2018  路  17Comments  路  Source: salesagility/SuiteCRM


Schedulers configured to run every few minutes run every minute.

Issue


If you set up a scheduler with interval in minutes, the final result is that this scheduler runs every minute.

Expected Behavior


If you set up a scheduler to run every 20 minutes, it should run every 20 minutes. Not every minute.

Actual Behavior


If you set up a scheduler with interval, for example, Every 20 Minutes the result is that this scheduler is executed every time that cron.php is executed. That is, every minute.

Possible Fix

Steps to Reproduce


  1. Create a custom ScheduledTask with a silly print on log (f.e Entering to test scheduler).
  2. Program a scheduler using the previously created job and set an interval of Every 20 minutes with Date & Time Start set to 01/01/2005 14:00 (this is important).
  3. Open the suitecrm.log and see that is running every minute.

scheduler_test

Your Environment

  • SuiteCRM Version used: Version 7.8.13
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Versi贸n 64.0.3282.119 (Build oficial) (64 bits)
  • Environment name and version (e.g. MySQL, PHP 7): PHP 7.0.25-0ubuntu0.16.04.1, MySQL 5.7.21-0ubuntu0.16.04.1
  • Operating System and version (e.g Ubuntu 16.04): Ubuntu 16.04 LTS
Important Fix Proposed Bug

Most helpful comment

@sanchezfauste @pgorod This also solves the issue for me! Thanks!

All 17 comments

Can you share your scheduler code..??

Possibilities will be either wrong interval pattern or you have missed returning true after successful business logic.

Hi @mustafa-taheri, here it is: scheduler_test.tar.gz

Hey @sanchezfauste I have tested it and its running in every 20 minutes interval attaching a screenshot in comment
screen_shot_2018-02-09_at_6_05_00_pm

I guess this link will help you for setting up CRON interval. Every-20-Mins

Hello again @mustafa-taheri ,

I have discovered an interesting thing: if you create the Scheduler using the interface in English, the bug does not appear. All works fine.

On the other hand, if you use a different language (in my case Spanish) the error appears...

What is your spanish language version?
Latest for your system here: https://sourceforge.net/projects/suitecrmtranslations/files/

Hi @horus68, my version is Spanish (Spain) 7.10.0.RC.2.

I have deleted Spanish (Spain) 7.10.0.RC.2 since it's an incorrect language pack version for my installed SuiteCRM version and installed Spanish (Spain) 7.9.11.1 and the issue is still present.

@pgorod cronjobs is your thing, right?! Can you replicate this with spanish and another language?

I use English and have the same issue. On a job to run every 5 minutes, it will fire when it's supposed to, then fire again once per minute for 5 minutes.

@sanchezfauste can you check how the job is created in the database, in each case (when it "works" in English, and when it "no funciona" in Spanish)?

The table is called schedulers and the field is job_interval

I want to check if the bug is when creating the job, or when selecting it for execution.

Hi @pgorod ,

I have observed the value of this field using Every 5 minutes condition and the result is:

job_interval in Spanish: */5::*::*::*::*
job_interval in English: */5::*::*::*::*

Now i'm experiencing the issue in both cases, using English or Spanish. In this case the test was made using SuiteCRM 7.10.

I'm on 7.10 RC, English, and setting a job for Every 20 minutes creates a row with job_interval as */20::*::*::*::* in the database, which seems correct.

Just to check, you selected Every 20 minutes, job_interval was created as */5::*::*::*::*, and the job runs every minute??

@pgorod sorry I have selected Every 5 minutes.

Selecting Every 20 minutes using Spanish language job_interval was created as */20::*::*::*::*, which seems to be correct but the job runs every minute.

Can you please turn up your Log level to debug, and post your log for one single execution of cron.php, when it runs the job although it shouldn't?

If possible to avoid any other SuiteCRM activity from users at the same time, that would help. Thanks

I have been debugging the execution of the Schedulers with log level to debug and I think I have found the error. With the changes applied in #5318 the Schedulers are executed correctly, that is, in my case, every 20 minutes.

Thank you very much for your help @pgorod, it has been useful to me when investigating the error.

@dhayner can you try my PR to see if your problem is solved?

@sanchezfauste @pgorod This also solves the issue for me! Thanks!

I have updated the description of the issue to make easier to replicate the error. I think you have not been able to replicate the error because you have used a value for Date & Time Start different from the one I used. The error occurs depending on the value of Date & Time Start and Interval. This can easily be seen by looking at the code, specifically it depends on the value of the variable $startFrom, if the value of this variable is 0 the bug occurs:

https://github.com/salesagility/SuiteCRM/blob/c6bece6ab3acd29365f5fc663ba8f3cc359a986b/modules/Schedulers/Scheduler.php#L412-L423

Was this page helpful?
0 / 5 - 0 ratings