0
votes

I have a file named cron.php that exists in the application/controllers/admin directory in my CodeIgniter project.

From what I understand, the correct cron command to perform the "test" method in the cron.php file in cPanel would be:

/opt/php56/bin/php /home4/username/public_html/index.php cron test

However, the cron.php is in an admin folder in the controllers folder. Does that mean I have to do something like:

/opt/php56/bin/php /home4/username/public_html/index.php admin/cron test

How would I go about doing this?

2
check my answer here: stackoverflow.com/questions/36186258/… and also this one: stackoverflow.com/a/46910528/2275490 hopefully it can point you into the right direction - Vickel

2 Answers

-2
votes

Running a php script using the php bin does no thing to do with the framework you are using. It is just a script to execute. This means, to run correctly your script in the cron, you need to give it the absolute path to it regardless your website or the framework you are using. So if the file is physically located in /data/site/public_html/cron.php, this is the path you need to give to cron If your cron runs the script as a url, then you need to give the url

0
votes

As code under Codeigniter cannot be executed directly, as we will be having no direct access statement at top of every file. you can use as follows * * * * * /usr/bin/curl https://www.example.com/controller/function