![](/img/trans.png)
[英]PHP Cron Problems - using plesk: dynamic library, open_basedir
[英]php script as cron using plesk 10.3.1
我一直在運行一個簡單的PHP腳本(它將其運行時間記錄在一個文本日志文件中)。 從瀏覽器可以正常運行,但是當我在plesk 10.3.1面板中使用計划的任務時,如下所示:
*/5 * * * * php /var/www/vhosts/eblogs.co.uk/httpdocs/frostbox/cron/crone_test.php
它會在五分鍾后立即運行,但不會在文本文件中寫入任何內容,並通過電子郵件向我發送以下通知消息:
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
我應該在下面的行中添加什么?
php /var/www/vhosts/eblogs.co.uk/httpdocs/frostbox/cron/crone_test.php
您返回的文本是piconv的使用消息。 這與腳本語言PHP完全無關。 您可能想要做的是以下之一:
您需要在系統上調用實際的php解釋器。 這可能是/usr/bin/php5
,所以您的crontab行看起來像
*/5 * * * * /usr/bin/php5 /var/www/vhosts/eblogs.co.uk/httpdocs/frostbox/cron/crone_test.php
但是,並非每個安裝程序都安裝了此命令行解釋器。 可能僅安裝了apache模塊。
如果您無權安裝命令行工具,請查看是否已安裝wget或curl。 如果是這樣,您可以使用它們通過向Web服務器發送請求來調用腳本。
/usr/bin/wget -O /dev/null 'http://eblogs.co.uk/crone_test.php'
-O /dev/null
告訴它將腳本生成的網頁保存在/dev/null
。 這是一個特殊的文件,基本上會立即忘記寫入其中的所有數據。 因此,此參數可避免創建帶有網頁內容的任何新文件並將其放置在服務器的文件系統中。
/usr/bin/curl -o /dev/null 'http://eblogs.co.uk/crone_test.php'
-o /dev/null
與上面帶有wget大寫字母O的版本具有相同的功能。
您可以使用“ curl” ...像這樣:
curl "http://eblogs.co.uk/crone_test.php"
在php腳本的頂部添加以下內容:
#!/usr/bin/php
<?php
your code here
?>
(假設php位於/ usr / bin中)
希望能有所幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.