1回答
- 新しい順
- 投票が多い順
- コメントが多い順
0
To run a cron job that connects to an RDS database from an Elastic Beanstalk application, you can use a .ebextensions configuration file.
Place a file such as 01_cronjob.config in a .ebextensions directory at the root of your application source code.
The file should contain:
files:
"/etc/cron.d/cronjob" :
mode: "000644"
owner: root
group: root
content: |
*/5 * * * * root cd /var/app/current && ./script.sh >> /var/log/cronjob.log 2>&1
This will run the script.sh file inside your application directory every 5 minutes.
The script can then connect to the RDS database using the RDS_HOSTNAME, RDS_USERNAME, RDS_PASSWORD environment variables provided by Elastic Beanstalk.
Make sure to grant access to the security group of your EC2 instances to connect to the RDS port from its IP range.
関連するコンテンツ
- AWS公式更新しました 3年前