Reputation: 73
$old = umask(0);
mkdir($_SERVER['DOCUMENT_ROOT'].'/images/'.$ID.'/', 0755, true);
umask($old);
Running this lines from browser works fine, instead if I run this script via a scheduled task, it gives:
'mkdir(): Permission denied'.
Version Plesk Onyx v17.0.17_build1700161028.14 os_CentOS 7
OS CentOS Linux 7.4.1708 (Core)
nginx 1.11.10-centos7.17102311
php 5.4.16-43.el7_4
Upvotes: 0
Views: 189
Reputation: 3300
When the script is executed via a browser, domain PHP handler with the corresponding configuration is used.
Scheduled PHP task is running using system PHP handler, therefore PHP configuration for the domain is ignored and $_SERVER['DOCUMENT_ROOT']
variable does not give the same result.
Try using Run a command
scheduled task type, using full path for required PHP binary and corresponding php.ini
. For PHP 7.0 shipped with Plesk and PHP configuration for example.com
domain:
/opt/plesk/php/7.0/bin/php -c /var/www/vhosts/system/example.com/etc/php.ini /path/to/script.php
The same but for system PHP:
/bin/php -c /var/www/vhosts/system/example.com/etc/php.ini /path/to/script.php
Upvotes: 1