2013-04-10 29 views
1

我幾乎成功地在我的服務器上設置了Cron作業,但我無法調用正確的控制器。cron守護進程沒有得到正確的控制器

工作:

*/15 * * * * php fullpath/index.php cron 

結果:我得到默認的控制器,而不是我的Cron控制器的HTML輸出。

工作:

*/15 * * * * php fullpath/index.php cron index 

結果:我得到默認的控制器,而不是我的Cron控制器的HTML輸出。

有人請指教我在做什麼錯?

注意:我不想用wgetcurl

+0

你做錯了什麼是假設'php index.php cron'作爲shell腳本以任何方式,形式或形式等同於向/ cron發出HTTP請求。不是。 – deceze 2013-04-10 05:55:22

+0

嘗試使用wget和url到您的控制器/方法........ – 2013-04-10 06:06:02

+0

Wget返回以下錯誤:發送HTTP請求,等待響應... 404未找到 2013-04-10 12:13:51未找到錯誤404。 – 2013-04-10 06:41:54

回答

0

創建你的index.php的副本,cli.php命名。

在cli.php的開頭添加

#!/usr/local/bin/php 
<?php 

/* we don't need to be limited by...normal limitations */ 
set_time_limit(0); 
ini_set('memory_limit', '256M'); 

/* make sure this isn't being called by a web browser */ 
if (isset($_SERVER['REMOTE_ADDR'])) die('Permission denied.'); 

/* set some constants */ 
define('CMD', 1); 

/* manually set the URI path based on command line arguments... */ 
unset($argv[0]); /* ...but not the first one */ 
$_SERVER['QUERY_STRING'] = $_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'] = '/' . implode('/', $argv) . '/'; 

然後改變你的cron改爲調用的index.php cli.php。

相關問題