Reputation: 498
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
Upvotes: 0
Views: 2939
Reputation: 1082
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:
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.
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.
/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.
/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.
Upvotes: 1
Reputation: 97
You can use "curl" ... like this:
curl "http://eblogs.co.uk/crone_test.php"
Upvotes: 0
Reputation: 3875
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 !
Upvotes: 0