我在 AWS Elastic Beanstalk
有两个环境:Development
和 Production
.
我想要那个 .ebextensions/app.config
仅在 Production
上运行环境。
有没有办法做到这一点?
应用程序配置:
container_commands:
01-command:
command: "crontab .ebextensions/cronjob"
leader_only: true
最佳答案
根据 TNICHOLS
想法我找到了一个解决方案:
换环境PARAM1
变量值为 MyAppEnv-Production
(或你想要的)。
应用程序配置:
container_commands:
command-01:
command: "/bin/bash .ebextensions/crontab.sh"
leader_only: true
crontab.sh:
if [ "$PARAM1" == "MyAppEnv-Production" ]; then
crontab -l > /tmp/cronjob
#CRONJOB RULES
echo "00 00 * * * /usr/bin/wget http://localhost/cronexecute > /dev/null 2>&1" >> /tmp/cronjob
crontab /tmp/cronjob
rm /tmp/cronjob
echo 'Script successful executed, crontab updated.'
else
echo 'This script is only executed in the production environment.'
fi
关于amazon-web-services - 适用于特定环境的 AWS Elastic Beanstalk : . ebextensions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16927868/