![]() |
Where to set CI_ENV for CI methods executed via cron? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: Where to set CI_ENV for CI methods executed via cron? (/showthread.php?tid=67800) Pages:
1
2
|
RE: Where to set CI_ENV for CI methods executed via cron? - VTCAhmedabad - 04-13-2017 (04-11-2017, 09:57 PM)Diederik Wrote: Or you could just run wget with a url as a cron. This answers is useful RE: Where to set CI_ENV for CI methods executed via cron? - spjonez - 04-13-2017 (04-11-2017, 07:28 AM)sneakyimp Wrote: Thank you for your response! 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. RE: Where to set CI_ENV for CI methods executed via cron? - Narf - 04-18-2017 When you open your .bashrc file, note this comment near the very top of the script: Quote:# If not running interactively, don't do anything Crontab jobs are non-interactive, and your .bashrc halts there - that's why you don't get your environment variables. If you really insist on using CI_ENV for this (there's nothing wrong with changing a line or two in index.php), just put your exports above that comment line. RE: Where to set CI_ENV for CI methods executed via cron? - Narf - 04-18-2017 (04-13-2017, 01:53 AM)VTCAhmedabad Wrote:(04-11-2017, 09:57 PM)Diederik Wrote: Or you could just run wget with a url as a cron. No, that answer is spreading bad practice. |