skip to Main Content

I’ve been running a simple php script (which logs its running time in a text log file). From browser it runs fine, but as I use the scheduled tasks in my plesk 10.3.1 panel as follow:

*/5 *   *   *   *   php /var/www/vhosts/eblogs.co.uk/httpdocs/frostbox/cron/crone_test.php

It does run right after five minutes but does not write anything in the text file and sends me following notification messages via email:

php [-f from_encoding] [-t to_encoding] [-s string] [files...]
php -l
php -r encoding_alias
 -l,--list
    lists all available encodings
 -r,--resolve encoding_alias
   resolve encoding to its (Encode) canonical name
 -f,--from from_encoding
    when omitted, the current locale will be used
 -t,--to to_encoding
    when omitted, the current locale will be used
 -s,--string string
    "string" will be the input instead of STDIN or files
The following are mainly of interest to Encode hackers:
 -D,--debug          show debug information
 -C N | -c | -p      check the validity of the input
 -S,--scheme scheme  use the scheme for conversion

What should I add in the following line?

php /var/www/vhosts/eblogs.co.uk/httpdocs/frostbox/cron/crone_test.php

3

Answers


  1. Add the following at the top of the php script:

    #!/usr/bin/php
    <?php
      your code here
    ?>
    

    (assuming php exists at /usr/bin)

    Hope that helps !

    Login or Signup to reply.
  2. You can use “curl” … like this:

    curl "http://eblogs.co.uk/crone_test.php"
    
    Login or Signup to reply.
  3. The text you get back is the usage message of piconv. This has absolutely nothing to do with PHP, the scripting language. What you probably want to do is one of the following:

    Alternative 1: Using the PHP command line interpreter

    You need to call the actual php interpreter on your system. This might be /usr/bin/php5, so your crontab line would look like

    */5 *   *   *   *   /usr/bin/php5 /var/www/vhosts/eblogs.co.uk/httpdocs/frostbox/cron/crone_test.php
    

    However not every setup has this command line interpreter installed. It might happen that only the apache module is installed.

    Alternative 2: Using an HTTP(S) request

    If you don’t have the right to install the command line tool, have a look if wget or curl is installed. If so, you can use them to invoke the script by sending a request to the web server.

    Using wget:

    /usr/bin/wget -O /dev/null 'http://eblogs.co.uk/crone_test.php'
    

    -O /dev/null tells it to save the web page generated by your script in /dev/null. It is a special file that basically immediately forgets all data written to it. So this parameter avoids that any new file with the web page contents is created and lies around in your server’s file system.

    Using curl:

    /usr/bin/curl -o /dev/null 'http://eblogs.co.uk/crone_test.php'
    

    -o /dev/null has the same function here as the version with the capital O above for wget.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search