• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

Issue PHP Cronjob in Plesk -- Lack of documentation. Lack of structure. Multiple Issues.

MHC_1

Regular Pleskian
Server operating system version
Alma Liux 9.7
Plesk version and microupdate number
Obsidian 18.0.76#2
As I have found with various posts over the last year on this forum; Cron Job or "Scheduled Tasks" in Plesk interface are an utter mess and lack any meaningful documentation.

I come from a system that has a perfectly working Cron Job (WHM) with very thorough documentation and structuring - so I'm not used to this.

If people in this forum are able to explain the below and guide how to work around these obstacles that would be amazing. And you should probably be employed by Plesk to write their documentation.

ISSUES

There is a Cron Job running on the server. PLEASE SEE THIS QUESTION: https://talk.plesk.com/threads/cron...tasks-lacks-documentation.393753/#post-982627 . The Cron job prints Error logs to the email, but does NOT print "print" output anywhere. Previously I have used "null two larger-than ampersand one" in the cron instruction but there's no documentation if that's needed in the Plesk environment or not .

ISSUE 1:

Error logs write to email rather than writing to designated file.

Code:
$sdr = "/var/www/vhosts/server.co.uk/public_html";
$errorLog = "/var/www/vhosts/server.co.uk/error/cron_reports.txt";

error_log("error reported ok", 3, $errorLog);

The Error log never writes to the file.
The Error log never writes this to the email output (where undesignated error logs are reported).

ISSUE 2:

Error logs should be reported to the designated error log file, rather than to email output. OR Errors to email output should ALSO be reported to the designated file.

Cronjob folder contains:
-- Cronfile.php
-- Account-user.ini (as designated in the account PHP file.

DOES PLESK USE A SEPARATE PHP DRIVER FOR CRON JOBS THAN USED FOR THE WEBSITE DELIVERY?? IF SO; HOW TO EDIT IT IN THE SAME WAY WEBSITE PHP.INI SETTINGS ARE EDITED?!?!?!


ISSUE 3:


Cron Job PHP finds the included "required" class in the below:


Code:
$sdr = "/var/www/vhosts/server.co.uk/public_html";
$errorLog = "/var/www/vhosts/server.co.uk/error/cron_reports.txt";
require "class.database.inc.php";

error_log("error reported ok", 3, $errorLog);


try {
   $dataBase = new Database($sdr.'/includes/classes/connection.dbxlink.php', true);
} catch (Exception $ex) {  

    // This below error log is never triggered. But the script exits as per the exit command. 

    error_log("Exception caught on initialization of class on " . __FILE__ . " on line " . __LINE__ . " :: " . $ex->getMessage(), 3, $errorLog);
    exit;
}

Inside the Class:


Code:
// __Contruct


if (is_file($this->connectionFile)) {
   include($this->connectionFile);
}
else {

       
        $errorMsg = "DBX connection file unfound: ".$this->connectionFile."

    }


The "Else" code ALWAYS triggers, The Cron job can't "find" a file that exists in the file path.

but the email contains: the correct address :


DBX connection file unfound: /var/www/vhosts/server.co.uk/public_html/includes/classes/connection.dbxlink.php


BUT THIS FILE EXISTS!!!!


This exact class and fle is successfully used by the Website PHP.


See image: https://talk.plesk.com/attachments/screenshot-from-2026-03-12-09-54-51-png.29215/ as well.


How do I get Cron Jobs to work in Plesk?
 
Because there's a fault with the forum and I can;t edit the original post; small addition:

re code block in ISSUE 3:

Code:
else {
        $errorMsg = "DBX connection file unfound: ".$this->connectionFile."
        error_log($errorMsg);
    }

This sends an email as intended but the whole script never writes to any designated error log file.
 
UPDATE:

Further to the above, the /var/log/cron file has some details:


Mar 16 22:10:02 servername CROND[3172277]: (account) CMD (/opt/plesk/php/8.3/bin/php -f 'cronz/calProcessing.php')
Mar 16 22:10:02 servername CROND[3172255]: (account) CMDEND (/opt/plesk/php/8.3/bin/php -f 'cronz/calProcessing.php')

Also, Terminal:

[root@servername ~]# ps ax | grep cron | grep -v auto
573061 ? Ss 3:00 /usr/sbin/crond -n

As per How to ensure that the cron service is working on a server - Support Cases from Plesk Knowledge Base
 
Back
Top