<bdo id='fiejI'></bdo><ul id='fiejI'></ul>
      <i id='fiejI'><tr id='fiejI'><dt id='fiejI'><q id='fiejI'><span id='fiejI'><b id='fiejI'><form id='fiejI'><ins id='fiejI'></ins><ul id='fiejI'></ul><sub id='fiejI'></sub></form><legend id='fiejI'></legend><bdo id='fiejI'><pre id='fiejI'><center id='fiejI'></center></pre></bdo></b><th id='fiejI'></th></span></q></dt></tr></i><div id='fiejI'><tfoot id='fiejI'></tfoot><dl id='fiejI'><fieldset id='fiejI'></fieldset></dl></div>
      <tfoot id='fiejI'></tfoot>
    1. <small id='fiejI'></small><noframes id='fiejI'>

      <legend id='fiejI'><style id='fiejI'><dir id='fiejI'><q id='fiejI'></q></dir></style></legend>

        AWS Elastic Beanstalk:运行 Cron.d 脚本,缺少环境变量

        时间:2023-08-18

            • <bdo id='pfubs'></bdo><ul id='pfubs'></ul>
              <legend id='pfubs'><style id='pfubs'><dir id='pfubs'><q id='pfubs'></q></dir></style></legend>

              • <small id='pfubs'></small><noframes id='pfubs'>

                <i id='pfubs'><tr id='pfubs'><dt id='pfubs'><q id='pfubs'><span id='pfubs'><b id='pfubs'><form id='pfubs'><ins id='pfubs'></ins><ul id='pfubs'></ul><sub id='pfubs'></sub></form><legend id='pfubs'></legend><bdo id='pfubs'><pre id='pfubs'><center id='pfubs'></center></pre></bdo></b><th id='pfubs'></th></span></q></dt></tr></i><div id='pfubs'><tfoot id='pfubs'></tfoot><dl id='pfubs'><fieldset id='pfubs'></fieldset></dl></div>
              • <tfoot id='pfubs'></tfoot>
                  <tbody id='pfubs'></tbody>
                1. 本文介绍了AWS Elastic Beanstalk:运行 Cron.d 脚本,缺少环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试运行由 cron 脚本(在 cron.d 中)触发的 PHP 脚本.该脚本已正确触发,但缺少存储在 $_SERVER 超全局变量中的 Elastic Beanstalk环境变量".该脚本目前以用户root"身份运行,但它不在具有环境变量的同一环境中.变量设置正确,如果我从完整的 shell 运行脚本,它运行得很好.

                  I'm trying to run a PHP script that is triggered by a cron script (in cron.d). The script is triggered properly but it is missing the Elastic Beanstalk "Environment Variables" that are stored in the $_SERVER superglobal. The script is being run as the user "root" for now, but it's not in the same environment that has the environment variables. The variables are set correctly, if I run the script from a full shell it runs just fine.

                  这些变量的导出"在哪里?他们在哪里设置?我在/etc/apache/conf.d/aws_env.conf 中找到了 Apache 的 SetEnvs.我在用户的 .bashrc、.bash_profile 等文件中找不到任何内容.有解决方法吗?有更好的方法吗?

                  Where are the "exports" for these variables? Where do they get set? I found the SetEnvs for Apache in /etc/apache/conf.d/aws_env.conf. I can't find anything in the user's .bashrc, .bash_profile, etc. Is there a workaround? A better way to do this?

                  谢谢.

                  推荐答案

                  我刚刚发现这个,使用

                  grep -r "export MY_VAR" /
                  

                  亚马逊似乎不时移动文件位置.当前位置是:

                  Amazon seems to move the file location from time to time. Current location is:

                  /opt/elasticbeanstalk/support/envvars
                  

                  所以我想我会在调用我的 php 脚本之前在我的脚本中包含 (source [file path]) .似乎仍然是一种时髦的做事方式.我仍在寻找更好的解决方案.

                  So I think I'll just include (source [file path]) that in my script before calling my php script. Still seems like a funky way to do things. I'm still in for better solutions.

                  我通过 cron 触发的 bash 脚本运行 PHP.所以要设置环境,我会做这样的事情:

                  I was running PHP via bash script triggered by cron. So to setup the environment, I would do something like this:

                  #!/bin/bash 
                  source /opt/elasticbeanstalk/support/envvars
                  php -f my-script.php
                  

                  有关 PHP 解决方案,请参阅下面@userid53 的回答.

                  See @userid53's answer below for PHP solution.

                  这篇关于AWS Elastic Beanstalk:运行 Cron.d 脚本,缺少环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Cronjob 但对于 jQuery/Javascript 下一篇:PHP CLI - 在后台执行操作的同时获取用户输入

                  相关文章

                2. <i id='VzgLB'><tr id='VzgLB'><dt id='VzgLB'><q id='VzgLB'><span id='VzgLB'><b id='VzgLB'><form id='VzgLB'><ins id='VzgLB'></ins><ul id='VzgLB'></ul><sub id='VzgLB'></sub></form><legend id='VzgLB'></legend><bdo id='VzgLB'><pre id='VzgLB'><center id='VzgLB'></center></pre></bdo></b><th id='VzgLB'></th></span></q></dt></tr></i><div id='VzgLB'><tfoot id='VzgLB'></tfoot><dl id='VzgLB'><fieldset id='VzgLB'></fieldset></dl></div>
                  <legend id='VzgLB'><style id='VzgLB'><dir id='VzgLB'><q id='VzgLB'></q></dir></style></legend>

                    <bdo id='VzgLB'></bdo><ul id='VzgLB'></ul>

                  <tfoot id='VzgLB'></tfoot>

                  <small id='VzgLB'></small><noframes id='VzgLB'>