0
votes

My Codeigniter Project Cron Job Not Working Correct

/usr/local/lib/php /home/{username}/public_html/index.php MyCron index

but my Cron Not work Correct and call Default Home Controller i need to call my MyCron Controller and index Function

So please help me

2
Most problems with cron jobs failing when they work for you from the command line (you did test that, right) is that the environment that cron spawns the job with is very limited. The man page for cron (usually) says that. You can search around SE (search "cron environment" got me a lot), there are lots of other questions about that, with many different useful suggestions. What works best depends on your specific details (not provided in your question). - MAP

2 Answers

0
votes

This could be because a couple of things. First of all, it could be because you have the wrong path for php. The path on my server is:

/usr/bin/php

You can find your path by typing:

whereis php

Second of all, it could be because you haven't installed the packages neccesary on your server. You need the package php cli

sudo apt-get install php5-cli

Lastly, your cron controller may contain errors, I recommend checking your log file, if you see any errors. For me, the crontab job that is working is:

0 10 * * * /usr/bin/php /var/www/<MY_PROJECT_NAME>/index.php Cron

So yes you can indeed use capitalized words when calling your controller.

-1
votes

Your controller should not be capitalised

/usr/local/lib/php /home/{username}/public_html/index.php mycron index

also index method should not be required as it is the default method.