Categories
Server Web Development

CodeIgniter Cron In Different Environment

Here are few ways on how to run CodeIgniter cron through your command line interface (CLI).

Default way

This way is to just run the cron regardless of the environment. But by default it will use “development”.

* * * * * php path/to/your/codeigniter/index.php controller method "parameters"

With Environment

The setup below helps you once you are working on different environment. If you are using version before 3, you need to use ENVIRONMENT as your server variable.

# Version 2.2 and below
* * * * * export ENVIRONMENT="testing"; php path/to/your/codeigniter/index.php controller method "parameters"
# Version 3+
* * * * * export CI_ENV="testing"; php path/to/your/codeigniter/index.php controller method "parameters"

I hope those simple snippets above will help you. Drop some comments if you have some or any suggestions. Thanks.

Leave a Reply Cancel reply