Jump to content

Issue with Automatic Execution of CRON Script in WHMCS


omidch4

Recommended Posts

Hello everyone,

I am experiencing an issue with the automatic execution of a CRON script in WHMCS. I have configured the CRON job in cPanel, and it successfully runs every 5 minutes. Additionally, manual execution of the script through SSH produces the expected results.

SSH Log:

Dec 10 17:50:01 server CRON[1923158]: (username) CMD (/opt/cpanel/ea-php74/root/usr/bin/php -q /home/username/public_html/crm.mysite.com/crons/cron.php) 

I have configured the time zone settings in both WHMCS and PHP as follows:

  • In php info: date.timezone: Asia/Tehran
  • In configuration.php: date_default_timezone_set('Asia/Tehran');

Furthermore, executing the following command manually produces the expected results:

/opt/cpanel/ea-php74/root/usr/bin/php -q /home/username/public_html/crm.mysite.com/crons/cron.php all -F -vvv 

However, despite these configurations, the script does not run automatically at 04:00 AM. I recently migrated the site from CyberPanel to cPanel. Can anyone provide insights into potential reasons for this issue? I appreciate any guidance and assistance you can provide.

Thank you for your help.

Link to comment
Share on other sites

On 12/12/2023 at 6:59 AM, radwebhosting said:

When you run the command manually, and it is successful, are you running as the same username as when it fails?

 

Hi, thank you for your reply. I probably did not understand your question correctly.
I login the server command line with root access and enter the following command:

/opt/cpanel/ea-php74/root/usr/bin/php -q /home/MyCrmUsername/hidefile/crons/cron.php all -F -vvv 

Also, instead of MyCrmUsername, I put the correct user and directory on which WHMCS is installed.
When I run this command. The Cron Job runs well and displays a success message. Also, there is no error in the automation in the WHMCS admin panel.
I moved the Crons directory to another folder and paths $whmcspath and  $crons_dir are correct.

But after a day, there are (Cron Invocation Frequency) (Daily Cron Run) (Daily Cron Completing) errors again in the automation management panel and the cron job is not done automatically every day.
I have to manually run the command line every day to create invoices.
My timezone is ok. my cron job setting in cpanel every 5 min is ok. my automation setting in whmcs panel is ok. So why doesn't the automation run automatically every day at 4 am?

sorry my bad English. TNX

Link to comment
Share on other sites

19 hours ago, GoZen said:

Sounds like not enough time to complete, check your PHP setting.

My max_execution_time is 300. memory is 64M
but not working.

I use this in cpanel cronjob and works fine:

0 	4 	* 	* 	*      /opt/cpanel/ea-php74/root/usr/bin/php -q /home/username/hidefile/crons/cron.php all -F -vvv

Does this cause a problem?

Link to comment
Share on other sites

On 12/10/2023 at 12:34 PM, omidch4 said:

Additionally, manual execution of the script through SSH produces the expected results.

SSH Log:

Dec 10 17:50:01 server CRON[1923158]: (username) CMD (/opt/cpanel/ea-php74/root/usr/bin/php -q /home/username/public_html/crm.mysite.com/crons/cron.php) 

I assume the above is logged from the scheduled cron?

On 12/10/2023 at 12:34 PM, omidch4 said:

Furthermore, executing the following command manually produces the expected results:

/opt/cpanel/ea-php74/root/usr/bin/php -q /home/username/public_html/crm.mysite.com/crons/cron.php all -F -vvv 

One thing you may want to explore if this issue persists is to set the above command to run daily as a system user with root-equivalent permissions (wheel-group user).

On 12/19/2023 at 11:56 AM, omidch4 said:

My max_execution_time is 300. memory is 64M

Check your error logs to see whether you notice out of memory issues logged during the daily cron. If not, then the memory limit is probably not the cause. (Although, I think it's a bit low as @GoZen mentioned.)

Out of curiosity, what version of WHMCS are you running? I know some versions that required additional cron job schedule for daily tasks.

Link to comment
Share on other sites

On 12/10/2023 at 12:34 PM, omidch4 said:

Additionally, manual execution of the script through SSH produces the expected results.

SSH Log:

Dec 10 17:50:01 server CRON[1923158]: (username) CMD (/opt/cpanel/ea-php74/root/usr/bin/php -q /home/username/public_html/crm.mysite.com/crons/cron.php) 

I assume the above is logged from the scheduled cron?

On 12/10/2023 at 12:34 PM, omidch4 said:

Furthermore, executing the following command manually produces the expected results:

/opt/cpanel/ea-php74/root/usr/bin/php -q /home/username/public_html/crm.mysite.com/crons/cron.php all -F -vvv 

One thing you may want to explore if this issue persists is to set the above command to run daily as a system user with root-equivalent permissions (wheel-group user).

On 12/19/2023 at 11:56 AM, omidch4 said:

My max_execution_time is 300. memory is 64M

Check your error logs to see whether you notice out of memory issues logged during the daily cron. If not, then the memory limit is probably not the cause. (Although, I think it's a bit low as @GoZen mentioned.)

Out of curiosity, what version of WHMCS are you running? I know some versions that required additional cron job schedule for daily tasks.

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