No Code Attached Yet
avatar bascherz
bascherz
25 Oct 2024

Steps to reproduce the issue

Use the Cron method to schedule a task on the same day/time every month. My case has this task running at 10:00am on the 20th of every month (every weekday).

  • Minutes: 0
  • Hours: 10
  • Days: 20
  • Months: all
  • Weekdays: all

Expected result

I expect the task to run once per month at 10:00. More specifically, I expected it to run on Oct 20, 2024 and next time after that on Nov 20.

Actual result

The task ran the first time at 10:00 on Oct 24, but it got stuck (see comments). So I stopped it and ran it manually around noon. The next time it ran was at 10:00 on Nov 20, 2024, and it has been running every 3 minutes since. It is still running every 3 minutes as of the time of this writing. What locked-in the 3-minute interval is a mystery.

System information (as much as possible)

  • Joomla! version: 5.2.0 Stable [ Uthabiti ] 15-October-2024 16:00 GMT
  • PHP Version: 8.2.24
  • PHP Built On: Linux na8861.serversignin.com 4.18.0-477.10.1.lve.el8.x86_64 #1 SMP Wed May 17 07:12:55 EDT 2023 x86_64
  • Database Type: mysql
  • Database Version: 10.11.9-MariaDB
  • Database Collation: utf8mb4_unicode_ci

Additional comments

  • The task eventually gets stuck and does not complete running (running man icon shown on task). I have the cronjob running the task scheduler every minute and the Joomla scheduler timeout set to 55 seconds. It appears the running man icon indicates the task did not complete before the next scheduler Cron "tick". This should not be possible considering how little the task does.
  • The task runs perfectly every time the Run Test button is clicked.
  • The Run Test button changes the Next Scheduled Time. It should never do this. The schedule, regardless what method is used, should be honored and never modified if a test is run. I have a suspicion that 3 minutes passed between me stopping the task and clicking Run Test.
  • UPDATE 1: Testing with 5-minute interval. Runs at correct interval. Task should be sending an email, but it seems that might be what is causing it to not finish. FIX: Hanging was due to using getCfg() instead of just get() to get site parameters. Interesting that before discovering this, the task worked when "Run Test" (Run Task??) is clicked, but not on a scheduled run.
  • UPDATE 2: Testing with 1-hour interval...working with interval setup. Working with cron setup.
  • UPDATE 3: Testing with 1-day interval...working with cron setup. Working with interval setup.

CONCLUSIONS:

  • It appears the "erratic" behavior I observed was actually CAUSED by the issue using getCfg() in my task versus get(). The task would get hung and not complete. Then the scheduler would eventually time it out and continue trying to run it. I think the retry interval when that happened ended up being 3 seconds for some reason.
  • The fact that getCfg() works with Run Test and not with a scheduled run maybe should be investigated, though that may be moot since getCfg() support is going away for Joomla! 6.
  • When saving the task, it is the Next Execution Time that matters initially and that seems to be getting set correctly every time now. The intervals and Cron scheduling appear to be working in this regard with 5.2.0, so that's an improvement over 5.1.4.
  • All tests passed. It seems the issue was entirely caused by my task using the deprecated application method getCfg(), which for some reason works fine with Run Test but not with a scheduled execution.

THIS TICKET CAN BE CLOSED.

avatar bascherz bascherz - open - 25 Oct 2024
avatar joomla-cms-bot joomla-cms-bot - change - 25 Oct 2024
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 25 Oct 2024
avatar bascherz bascherz - change - 25 Oct 2024
The description was changed
avatar bascherz bascherz - edited - 25 Oct 2024
avatar bascherz bascherz - change - 25 Oct 2024
The description was changed
avatar bascherz bascherz - edited - 25 Oct 2024
avatar Quy
Quy - comment - 25 Oct 2024

The Run Test button changes the Next Scheduled Time. It should never do this. The schedule, regardless what method is used, should be honored and never modified if a test is run.

See #36453 and PR #36725.

avatar bascherz
bascherz - comment - 25 Oct 2024

The Run Test button changes the Next Scheduled Time. It should never do this. The schedule, regardless what method is used, should be honored and never modified if a test is run.

See #36453 and PR #36725.

Well, that's an easy way out. Just change the button label. I think perhaps it's OK if Run Test (or Task) determines the next execution time if a method is used that does not specify a date and/or time. In those cases, the scheduler should always honor those settings.

avatar bascherz bascherz - change - 25 Oct 2024
The description was changed
avatar bascherz bascherz - edited - 25 Oct 2024
avatar bascherz bascherz - change - 26 Oct 2024
The description was changed
avatar bascherz bascherz - edited - 26 Oct 2024
avatar bascherz bascherz - change - 26 Oct 2024
The description was changed
avatar bascherz bascherz - edited - 26 Oct 2024
avatar bascherz bascherz - change - 26 Oct 2024
The description was changed
avatar bascherz bascherz - edited - 26 Oct 2024
avatar bascherz bascherz - change - 26 Oct 2024
The description was changed
avatar bascherz bascherz - edited - 26 Oct 2024
avatar bascherz bascherz - change - 28 Oct 2024
The description was changed
avatar bascherz bascherz - edited - 28 Oct 2024
avatar bascherz bascherz - change - 28 Oct 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-10-28 20:46:50
Closed_By bascherz
avatar bascherz bascherz - close - 28 Oct 2024

Add a Comment

Login with GitHub to post a comment