PROBLEM
I am using CodeIgniter v2.1.4 for my website. I have setup a cronjob to run every 2hours using the following command php -q /home/user_name/www/index.php controller my_method
. However this outputs my default controller pages html content (which is my home page's html content).
TRIED
I added another file to my www directory named test.php with a simple echo & it ran correctly, therefore I am sure the problem exists in CI. Also when I access the controller/method that I am trying to execute via a cron job using the browser, it outputs the correct message.
REQUIRED SOLUTION
I used wget -q http://mywebsite.com/controller/my_method
as suggested on another thread & it worked properly, but I want to use the php -q
way because then I will be able to reject direct access to my script from the browser.