Where to set CI_ENV for CI methods executed via cron? |
(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.
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. |
Welcome Guest, Not a member yet? Register Sign In |