I want to add one condition in cron.config
file. I need to check ENV_ID
(environment id) if the environment ID is a match with production server then cron will set in crontab else cron will not set check.
cron.config
container_commands:
01_remove_crontab:
command: "crontab -r || exit 0"
02_test:
command: |
ENV_ID=`{"Ref": "AWSEBEnvironmentId" }`
ENV_NAME=`{"Ref": "AWSEBEnvironmentName" }`
03_add_crontab:
test: [ $ENV_ID == "e-r19pphhp78l" ]
command: "cat .ebextensions/crontab | crontab"
leader_only: true
crontab
* * * * * wget https://example.com/cronrun.php >> /dev/null
Also, I check if condition but now working.
container_commands:
01_remove_crontab:
command: "crontab -r || exit 0"
02_test:
command: |
ENV_ID=`{"Ref": "AWSEBEnvironmentId" }`
ENV_NAME=`{"Ref": "AWSEBEnvironmentName" }`
ENV_MYID="e-r19pphhp78l"
03_add_crontab:
command: |
if [ $ENV_ID == $ENV_MYID ] then
"cat .ebextensions/crontab | crontab"
fi
leader_only: true
I am not able to found what missing and what's the wrong script.