2015-03-25 65 views
0

我只启用CLI要求:如何使用cron Jobs运行[Codeigniter]迁移?

if (! $this->input->is_cli_request()) { 
      echo 'Only access via command line.'; 
      exit;  
     } 

试过,没有运气命令:

*/5 * * * * 
cd /home4/shah/public_html/proof/oinvoices/; 
php index.php migrate reset; 
php index.php migrate latest; 

我想运行两个函数首先我想重置,则数据库名为最新版本的迁移。

既不显示错误,也不工作。

+0

那么,怎么了?当你运行cron时会发生什么/不会发生什么?你有没有收到任何错误信息?让我们轻松为您提供帮助,包括我们所需的所有信息。 – Styphon 2015-03-25 10:43:58

+0

它不工作,没有看到错误 – 2015-03-25 10:44:58

+0

你有服务器上的SSH访问吗? – Philip 2015-03-25 12:32:29

回答

1

你必须提供php.exe的路径,然后是函数路径。

我假设你有PHP版本5.3,

/opt/php53/bin/php /home4/shah/public_html/proof/oinvoices/index.php migrate reset 
/opt/php53/bin/php /home4/shah/public_html/proof/oinvoices/index.php migrate latest 
,如果你想运行一个cron作业,首先要在迁移功能

public function clean_up(){ 
    if (!$this->migration->version(0)) { 
     echo $this->migration->error_string(); 
    } 

    // unset table cache - this will force it to update 
    unset($this->db->data_cache['table_names']); 

    if (!$this->migration->latest()) { 
     echo $this->migration->error_string(); 
    } 
    } 

则:如果你是使用php5.3

/opt/php53/bin/php/home4/shah/public_html/proof/oinvoices/index .PHP迁移CLEAN_UP

如果你使用php5.4

的/ opt/php54 /斌/ PHP /home4/shah/public_html/proof/oinvoices/index.php迁移CLEAN_UP

希望能解决你的问题。

+0

clean_up函数给出错误, 不能声明table blah等等。如果你再次运行,它会顺利进行,没有任何错误。 – 2015-03-28 07:55:36

+0

它仍然给出相同的错误。 – 2015-03-28 08:06:06

+1

请按照[此链接](http://stackoverflow.com/questions/18545942/codeigniter-migration-cannot-redeclare-class)了解更多详情 – 2015-03-28 08:07:03