Jump to content

Cron running before it should


Linuc82

Recommended Posts

I have a strange issue that started last week.

My whmcs daily cron is set to execute at 00:00 in the automation settings.

For some strange reason it runs at 23:00 and then again at 0:00.  Every single night.

This is on an established system that has been running for years without any issues.

I've check the PHP Timezone as well as the server timezone.  also added date_default_timezone_set('America/Los_Angeles'); in the configuration.php file just in case.

I cannot find any reasonable explanation as to why it would run exactly 1 hour before the actual scheduled time, and then again at the time set in the automation settings.

If it was a timezone issue, it would then just execute at the wrong time, but in this case it runs twice, which is causing cron errors.

Running the cron by force in CLI it completes without an issue.

Link to comment
Share on other sites

Update:

I just discovered something very weird.

Right in the middle of the WHMCS Daily Cron run, the time changes 1 hour back:

 

07/11/2022 01:06 Email Sent to ***** (Domain Renewal
07/11/2022 01:06 Domain Renewed Successfully - Domain ID
07/11/2022 02:06 Invoice Marked Paid - Invoice ID
07/11/2022 02:06 Running Automatic Domain Renewal on Payment

My Daily Cron is set to run at 2am.  See how mid-automation tasks the time changes from 2am to 1am.  This causes other issues, such as the cron reporting that it did finish.

Edited by Linuc82
Link to comment
Share on other sites

The server time, php time and whmcs configuration time is set to the exact same time.

So, I monitoring the Activity logs very closely over the last few days.

As mentioned, my Daily Cron starts off at the correct time, 2am.  But during the cron run it changes 1 hour back.  Monitoring the Activity Log I noticed that it happens every time during the "CreateInvoices" function run.

I "skip --CreateInvoices" during my 5 minute cron and moved it to it's own "do --CreateInvoices" set to 3am.  Bam, the Daily Cron finished without any errors.

The issue is definitely with "CreateInvoices".  Checking the Activity Logs again at 3am the system start off creating new invoices at 3am, but after 10 invoices or so, the time changed again from 03:01 to 02:01.

09/11/2022 02:01 Email Sent to O**** A****** (Domain Renewal: xxxxx)
09/11/2022 02:01 Domain Renewed Successfully - Domain ID: 200300 - Domain: xxxx
09/11/2022 03:01 Running Automatic Domain Renewal on Payment
09/11/2022 03:01 Invoice Marked Paid - Invoice ID: xxxx

 

At this point in time I don't think it is a timezone issue at all, rather that whmcs  cron starts recording the incorrect time at some point during the "CreateInvoices" function run.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated