Cron jobs in Plesk?

Hi guys.

Anyone here that knows how to setup cron jobs in Plesk?
We just moved to a new VPS server where we use Plesk to partition the server into various functions.

I been sitting for several hours searching and testing and so far I had no success.
It just fails with the following:

**Task "public_html/cron.php" completed with error in 0 seconds, output:**
Task "public_html/cron.php" completed with error in 0 seconds, output:
PHP Fatal error: Uncaught TypeError: imap_expunge(): Argument #1 ($imap) must be of type resource, bool given in /var/www/vhosts/
Stack trace:
#0 /var/www/vhosts/ imap_expunge()
#1 /var/www/vhosts/ ImapHandler->expunge()
#2 /var/www/vhosts/

I also tried to directly schedule the cron job in Plesk admin to run under www-data but that also fails.

I’ve also tried
But that is resulting in 500 internal server error when running cron by calling it from the browser.

I also attempted this suggestion:

with running it as wget. That also fails.

So honestly; I’m out of ideas… :bulb:

Would appreciate greatly any suggestion that would lead me on the right track.
Thanks! :smile:

It doesn’t look like you have a problem running cron jobs, what you have is a specific cron job giving a FATAL error…

Hmm if that is the case, then what can be done to fix it? :thinking:

The error seems to be inbound email. If you don’t need it, then disable that job, and the others should run fine. Keep an eye on Admin / Schedulers, enter each job and check “Last ran successfully” field to understand what’s happening.

If you need it, you need to figure out which part of the inbound email configuration is broken… which can be a tricky thing to do

1 Like

Thanks @pgr I’ll look into it.

It could not just be a matter of corrupted files?

I mean normally this should work out of the box right?

That FATAL looks just like the IMAP errors that people are getting with the new changes in Microsoft Accounts. It simply looks like the job that grabs email is unable to do so (and unable to fail gracefully)

1 Like

I found a solution @pgr. :+1:
It all came down to the allowed user for cron jobs.

I created this file and called it test.php (Saved it in www root), and added this code:

echo get_current_user();

after that ran the test.php file in the browser which then prints the current user used for the cron jobs and changed it in the config.php file to that user.

  'allowed_cron_users' => 
    array (
      0 => 'www-data',
      1 => 'my-allowed-user-name',

Then after that setup the cron job in Plesk CP scheduled jobs as a php script:

Then hit the “Run Now” button to test and boom!
Its working! :smiley: :facepunch:

Kind regards

Nice. Can you please check the instructions at the bottom of Admin/Schedulers? Is your user well identified there?

I’m just checking if that code is running well

1 Like

Hi pgr.

Yes, the user is checking out nicely with what SuiteCRM tells you on that page too. :smiley:

Kind regards

1 Like