• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

End-User running a PHP Cron

KrazyBob

Regular Pleskian
Using the crontab manager within Plesk 8.0 a customer is unable to get their script to run using this syntax:

/usr/bin/php -f /var/www/vhosts/publicsafety.com/httpdocs/test.php

The cron runs once per minute and does run but returns a No Input File Specified PHP error.

How do they run a PHP script as a cron through the CP? We WERE able to run it using curl but figured that they should be able to run it the other way. In fact, if adding a cron through SSH it ruins just fine. Just not when setup through the CP.
 
When you add the cron job in SSH, what user are you using?

Have you verified that the client's user account is able to access all resources the php script calls, as well as /usr/bin/php itself?

Does the users account have a shell?

-Bill
 
The primary admin user and the account has /bin/sh shell access. The cron is only calling a PHP script that access mySQL. Therror being reported is Input File Not Specified. Not a PHP runtine error. The script may be called directly from the client bash line and runs fine. Just not from the Plesk cron manager.
 
I'm sorry, your answer was a bit confusing, to confirm you:

1. added the cron job, from the command prompt as both the admin user and the client user and both worked?

2. You verified that the client user has access to /usr/bin/php (ls -l /usr/bin/php).

Is the php script something you can share?
 
Let's recap.

The client is trying to add a cron within Plesk. It fails and Plesk emails the reason as No Input File Specified. The test script is a simple mailto() to show that the script is running.

The client has shell access as /bin/sh. The same script runs from the command line just fine as that user. The same script may be placed into a cron from the command line and runs just fine. BUT the script will not run from the Plesk cron manager unless it is done using curl:

curl http://publicsafety.com/test.php

The original method is what is failing from within Plesk but does not fail from the command line:

/usr/bin/php -f /var/www/vhosts/publicsafety.com/httpdocs/test.php

Since this runs fine from the command line it should be clear that the client has all the proper permissions.
 
I'm assuming that when you say you run it from the command line, you're running it as the client user because that's still not quite clear.

Assuming that, and that it also works if you create a cronjob as that user, ex:

Code:
crontab -e -u [I]client_username[/I]

And add the appropriate entry such as:

Code:
# Run every minute every day
* * * * *  /usr/bin/php -f /var/www/vhosts/publicsafety.com/httpdocs/test.php

And that works, then I would again add it using the Plesk GUI then list the crontab for that user from the shell:

Code:
crontab -l [I]client_username[/I]

to see how it was entered by Plesk. I created an entry just as you did and it fired off with out a hitch, the crontab looks just like above.

That's about all I can do for you, it's pretty simple stuff. My test account also did not have a shell, so that might help you a bit with that stuff.

BTW, you should be able to use "php -q" in lieu of "php -f" not sure why -f wouldn't work but it's another option.
 
I appreciate your help, but to me this is pretty clear :)

/usr/bin/php -f /var/www/vhosts/publicsafety.com/httpdocs/test.php

Run from the bash command line it executes properly. The same command placed into a cron from the command line also runs:

* * * * * /usr/bin/php -f /var/www/vhosts/publicsafety.com/httpdocs/test.php

I'll keep plugging away...
 
So, what does it look like when Plesk adds it to crontab? You realize it uses the same crontab right?

crontab is crontab, if you both are adding it the same way under the same unix username then it's time to format and restore. Seriously, add it through the GUI and the list the crontab

open up notepad and paste the exact line from your console window that PLESK adds, then try to run that same line (with out the crontab time entries).

The only thing I can think of is that it's adding a special character or something you can't see, like a null character, but I don't know why it would be doing that.

Lets start over, hi I'm Bill...

Open up a shell prompt, run this AGAIN.

Code:
crontab -e [I]client_username[/I]

delete everything in this file

go to the Plesk GUI as that user, add a new crontab for your application, go back to the shell prompt

Code:
crontab -l [I]client_username[/I]

cut and paste that line into notepad, make sure it looks right, no funky characters, then paste the command portion into the shell.

If it still works, take off and nuke the site from orbit, it's the only way to be sure. :0

-Bill
 
Hi I've got the same problem. I allowed the client to exectute shell commands.

I've got this crontabs:

Code:
# crontab -l -u sillymidget

*/5     *       *       *       *       /usr/bin/php -q -f /var/www/vhosts/domain.com/httpdocs/somescript.php >> /var/www/vhosts/domain.com/httpdocs/log.txt
53      *       *       *       *       pushd '/var/www/vhosts/domain.com/httpdocs/'; /usr/bin/php -q -e -f somescript.php >> log.txt; popd

When I run those from command line there are no problems. But no cron job is ever executed, and no error mail.

What should I do?
 
Silly question, you sure crond is running?

ps -ef | grep -i crond
 
Code:
# ps -ef | grep -i cron
root      1513     1  0 Jan11 ?        00:00:00 /usr/sbin/cron
root     22649 21480  0 12:34 pts/0    00:00:00 grep -i cron

Server wide cronjobs (like the statistics stuff) does run every night.
 
I'm at a loss... Probably a time to put in a support request. :|
 
I sent a support ticket on 15-1-2007 and didn't get an answer so far.

Did anyone find a solution yet?
 
Originally posted by DiLDoG
I sent a support ticket on 15-1-2007 and didn't get an answer so far.

Did anyone find a solution yet?
I have searched for ticket by your e-mail but couldn't find it. Could you specify it please and I will pass it to support team if it was not processed yet.
I have checked similar situation on my test server with 8.0.1 (latest patches installed) and everything working fine.
 
Support solved my problem already (even thou it was not a bug). So thnx allot anyway.
It appears the problem was the script permissions. :(

But I still think its weird that I didn't get a error email or something.
 
Back
Top