Welcome Guest, Not a member yet? Register   Sign In
Where to set CI_ENV for CI methods executed via cron?
#12

(This post was last modified: 04-13-2017, 11:11 AM by spjonez.)

(04-11-2017, 07:28 AM)sneakyimp Wrote: Thank you for your response!

This does in fact address the problem but is not ideal for two reasons:
1) one must specify the environment every single time one specifies a cron/cli command. My crontab is going to have a dozen commands in it, all of which would need to have this value specified.
2) edits to the index.php file can make upgrading CodeIgniter more difficult because you have to propagate these changes manually merge these changes with any made by the CI core.

Is there not one place we can specify this value that works for both cron jobs and for cli execution?

1) Yes you would need to do that. You have to specify it somewhere unless you change the code I posted to always set a specific CI_ENV when running from CLI which will make testing difficult. If you use a staging server it's CRON jobs need a different environment than production so hard coding it for all command line calls is not ideal.

2) You aren't wrong, but copy and pasting a single if/else block isn't going to make upgrades difficult. The upgrade guide says when you need to replace index.php which happens very infrequently.

(04-11-2017, 09:57 PM)Diederik Wrote: Or you could just run wget with a url as a cron.

You can but then your CRON jobs are web accessible and if someone finds a link to them they can run them over and over again which could cause problems if they are designed to run at specific intervals.
Reply


Messages In This Thread
RE: Where to set CI_ENV for CI methods executed via cron? - by spjonez - 04-13-2017, 11:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB