从cronjob调用Codeigniter控制器

I have created a cron job from cpanel. The command is

php /home/userdir/www/index.php Messages test

The controller Messages and the method test just inserts a record in a temporary table.

When I run the following from command prompt on my laptop running windows, it runs fine.

php c:/wamp/www/project/index.php Messages test

This works perfectly.

However, on the hosted server running Linux, I get a mail from the server which has the html for the home page. It does not even go to the Messages->test method.

Please help.

Use:

php index.php welcome show

as command in your crontab. E.g.:

0 * * * * php /home/userdir/www/index.php Messages test

or

0 * * * * /usr/local/bin/php /home/userdir/www/index.php Messages test

or

0 * * * * wget http://domain.com/Messages/test

http://www.codeigniter.com/user_guide/general/cli.html