• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Scheduled Task: executing php -f ... does not work anymore

Fritz MichaelG

Basic Pleskian
Under a particular domain, I had created the following scheduled task:
Code:
php -f /var/www/vhosts/somedomain/httpdocs/foo.php
This worked fine, up until exactly 2013-10-29 11:22 UTC+1. Then I constantly got the following error:
Code:
Could not open input file: /var/www/vhosts/somedomain/httpdocs/foo.php
Back then I logged into the shell and executed the command directly from the shell, to check whether it should work... and it did. The command kept failing though with that error message in the scheduled task. Now, over a month later, the error message changed to:
Code:
-: php: command not found
Still, the command is working fine directly from the shell.

I don't know what's going on, how can I execute php scripts from a scheduled tasks now? What has changed?
 
use the full path to the php bin if that can help...you can get it with which php
 
use the full path to the php bin if that can help...you can get it with which php
Good point, but no luck with that. According to
Code:
which php
the path is /usr/bin/php. However, when using that command in the scheduler, I just get:
Code:
-: /usr/bin/php: No such file or directory
 
Ok, now I get it, I think. Under Home > Subscriptions > domain > Websites & Domains > FTP Access the system user must have access to an appropriate shell. i.e. Forbidden, chrooted and /bin/rbash won't work, as those shells have no access to /usr/bin/php (not sure about /bin/bash and /bin/dash). Now I am back to my old error message:
Code:
Could not open input file: /var/www/vhosts/somedomain/httpdocs/foo.php
, but I think I can explain that as well. The script I want to run is the cron.php from ownCloud. However, my ownCloud installation is not running in CGI or FastCGI mode (since that didn't work), instead PHP is running as an Apache module. This in turn means, that I have set the owner of all files to www-data:www-data (the Apache User) which in turn means that the system user for that account cannot access these files, depending on the file permissions.

I am not sure how to circumvent this problem, other than setting the file permissions to 777 or trying to get the ownCloud to run under FastCGI again. I don't really understand why it was working before either - the file ownership was already set to www-data:www-data when the scheduled task was still working.
 
I do not like enabling any sort of shell for a hosting user, even if it is "me".

Does this script not allow you to wget or curl foo.php instead of running it directly? I so dislike scripts that want you to run things directly, because they are not suited to a shared hosting environment.

Alternatively, how about adding the cron task to the root crontab via the scheduled tasks in the admin side of things (Tools & Settings > Scheduled Tasks > select root, enter your task. Actually, now that I think about it, is there an apache option in the user drop-down? That might be better and a lot safer.

Be aware, however, that there are dangers doing things as root!
 
I do not like enabling any sort of shell for a hosting user, even if it is "me".
I get what you mean. And in this case, even a rooted shell is not sufficient, since it doesn't provide access to the php executable.


Does this script not allow you to wget or curl foo.php instead of running it directly? I so dislike scripts that want you to run things directly, because they are not suited to a shared hosting environment.
No, it's perfectly possible to trigger it with wget or whatever instead. I just prefer it the other way, for no particular reason in this case.


Alternatively, how about adding the cron task to the root crontab via the scheduled tasks in the admin side of things (Tools & Settings > Scheduled Tasks > select root, enter your task. Actually, now that I think about it, is there an apache option in the user drop-down? That might be better and a lot safer.

Be aware, however, that there are dangers doing things as root!
Yeah, I don't really like to run it as root though, for security reasons.
 
Back
Top