Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Cron / PHP file issue (fixed)
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.

Cron / PHP file issue (fixed)

WHTWHT Member
edited February 2016 in Help

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.

«1

Comments

  • apt-get install php5-cli

    Thanked by 1WHT
  • jarjar Patron Provider, Top Host, Veteran

    Is this root cron? If so, what is the exact error?

  • @Mun said:
    apt-get install php5-cli

    let me try

  • @WHT said:
    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/

    @jarland said:
    Is this root cron? If so, what is the exact error?

    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

  • RolterRolter Member
    edited February 2016

    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.

  • WHTWHT Member
    edited February 2016

    @Mun said:
    yum install php5-cli

    No package php5-cli available.

  • jarjar Patron Provider, Top Host, Veteran

    WHT said: 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

    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.

  • @Rolter said:
    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.

    Am on centos 6

  • @jarland said:
    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.

    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 ?

  • RolterRolter Member
    edited February 2016

    The first part still applies , you need to use absolute path for include files .

    Find
    include or include_ones or require or require_ones and the change the path of the included file with the full path to the file.

    Thanked by 1jar
  • Rolter said: 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.

    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

  • WHT said: 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.

    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

    PATH=$PATH
    

    below

    #!/bin/bash

    on debian usually solved my cron issues.

  • @Mun said:
    I assume at this point you are running Cpanel:

    http://www.webhostingtalk.com/showthread.php?t=1038378

    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 [~]#

  • WHT said: The script is working when I type it in browser. Without any error.

    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.

  • jarjar Patron Provider, Top Host, Veteran
    edited February 2016

    When random unprovoked detective work leads you to a multiaccount ban evader...

    Generally referred to as a day ending in Y.

  • @jarland said:
    When random unprovoked detective work leads you to a multiaccount ban evader...

    Generally referred to as a day ending in Y.

    rip x_x

    Thanked by 1jar
  • @jarland can I get a warning point(s) for trying to help a multiaccount ban evader!

    Thanked by 2trewq ATHK
  • Mun said: 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!

    Thanked by 1GM2015
  • @Jarland

    was it @goodhosting has he finally come back from his vacation ?

    Thanked by 2ATHK switsys
  • @jarland said:
    When random unprovoked detective work leads you to a multiaccount ban evader...

    Generally referred to as a day ending in Y.

    Does this mean no more ministerhosting?

  • @vedran said:
    For $7 you can get a fancy title which goes with it too!

    Where do i pay ?

  • Thanked by 2GM2015 GCat
  • php -f or -q /home/user/public_html/doc/path/ ?

    @WHT said:
    Maybe should I add some extensions like -q or -o ?

Sign In or Register to comment.