New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Cron / PHP file issue (fixed)
Hello.
Just paid someone on fiver to create me a script to auto-suspend reseller when is over quota. When I type it on browser it suspends but when I add it to run on cron, it wont. Its getting some errors like file does not exists etc.
Here is how I added:
*/5 * * * * /usr/bin/php /usr/local/cpanel/whostmgr/docroot/cgi/one/suspend.php
When I type in browser: http://server:2086/cgi/one/suspend.php it works.
Help please.
Comments
apt-get install php5-cli
Is this root cron? If so, what is the exact error?
let me try
is it cpanel? try with yum install php-cli
No package php5-cli available.
apt-get not installed and was following this tutorial but without success:
http://everyday-tech.com/apt-get-on-centos/
Yes its a root cron that should run every 5 min. There are errors like:
Warning: file_get_contents(one/one2): failed to open stream: No such file or directory in
But there is the file.
yum install php5-cli
If you have any file includes in your php script , make sure you are using absolute paths .
Also , if its a debian system , cron file permission needs to be 0666.
No package php5-cli available.
So what this means is that it's not returning an error running the file on cron, but the code inside the file is failing to find a file that it is searching for when executed via cron. This is usually due to some environment variable issue. You might look for a relative path in the file's code and try changing it to an absolute, for example.
Am on centos 6
The script is working when I type it in browser. Without any error.
I assume at this point you are running Cpanel:
http://www.webhostingtalk.com/showthread.php?t=1038378
Maybe should I add some extensions like -q or -o ?
The first part still applies , you need to use absolute path for include files .
Find
include
orinclude_ones
orrequire
orrequire_ones
and the change the path of the included file with the full path to the file.Was thinking the same. If PHP is on there, likely a working directory issue. Otherwise maybe a module is in his web server php config, but not on the CLI... if PHP is even there. Hard to tell without descriptive errors.
CentOS PHP packages well for PHP 5 anyway don't list a version number in yum so it'll be
yum install php-cli
But there is the file.
do this from console:
cd/usr/local/cpanel/whostmgr/docroot/cgi/ && /usr/bin/php one/suspend.php
If that doesn't work try:
cd/usr/local/cpanel/whostmgr/docroot/cgi/one/ && /usr/bin/php suspend.php
Which ever works put into your crontab with:
*/5 * * * *
infront.(For future reference give us more info when you post an problem otherwise we are shooting at blanks like I did with php5-cli.)
Adding
below
on debian usually solved my cron issues.
yes I have it:
root@dev [~]# php -v
PHP 5.5.31 (cli) (built: Jan 20 2016 14:30:58)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
root@dev [~]#
When you run the script in the browser, it's current directory will be website root, which is not the case if you run it from CLI. Also, the script might be using some environmental variables or superglobals (like $_SERVER for example) which are not available in CLI.
When random unprovoked detective work leads you to a multiaccount ban evader...
Generally referred to as a day ending in Y.
rip x_x
@jarland can I get a warning point(s) for trying to help a multiaccount ban evader!
For $7 you can get a fancy title which goes with it too!
@Jarland
was it @goodhosting has he finally come back from his vacation ?
Does this mean no more ministerhosting?
Where do i pay ?
php -f or -q /home/user/public_html/doc/path/ ?