AWS Elastic Beanstalk へのデプロイ中に、次の 2 つのことを行いたいと考えています。
- cron エントリを含むファイルを取得し、このファイルを /etc/cron.d/ に配置します
- 単一のディレクトリに含まれるシェル スクリプトのファイル アクセス許可を変更して、cron で実行できるようにします。
私の .ebextensions フォルダーには、次のものがあります。
container_commands:
00fix_script_permissions:
command: "chmod u+x /var/app/current/scripts/*"
01setup_cron:
command: "cat .ebextensions/propel_mis_crons.txt > /etc/cron.d/propel_mis_crons && chmod 644 /etc/cron.d/propel_mis_crons"
leader_only: true
また、.ebextensions フォルダーの propel_mis_crons.txt には次の内容があります。
# m h dom mon dow command
MAILTO="dev@23sparks.com"
* * * * * root /var/app/current/scripts/current_time.sh
デプロイ ログを確認したところ、次のことがわかります。
2013-08-09 14:27:13,633 [DEBUG] Running command 00fix_permissions_dirs
2013-08-09 14:27:13,633 [DEBUG] Generating defaults for command 00fix_permissions_dirs
<<<
2013-08-09 14:27:13,736 [DEBUG] No test for command 00fix_permissions_dirs
2013-08-09 14:27:13,752 [INFO] Command 00fix_permissions_dirs succeeded
2013-08-09 14:27:13,753 [DEBUG] Command 00fix_permissions_dirs output:
2013-08-09 14:27:13,753 [DEBUG] Running command 01setup_cron
2013-08-09 14:27:13,753 [DEBUG] Generating defaults for command 01setup_cron
<<<
2013-08-09 14:27:13,829 [DEBUG] Running test for command 01setup_cron
2013-08-09 14:27:13,846 [DEBUG] Test command output:
2013-08-09 14:27:13,847 [DEBUG] Test for command 01setup_cron passed
2013-08-09 14:27:13,871 [INFO] Command 01setup_cron succeeded
2013-08-09 14:27:13,872 [DEBUG] Command 01setup_cron output:
ただし、展開時に、スクリプト ディレクトリ内のすべてのファイルに対するアクセス許可が正しく設定されておらず、cron が実行されません。権限の問題が原因で実行されていないcronが実行されていないのか、それともこれを妨げている何かがあるのか わかりません。これは、PHP5.4 64 ビット Amazon Linux インスタンスで実行されています。
これに関するいくつかの支援をいただければ幸いです。今後、cron によってトリガーされる新しいシェル スクリプトが追加される可能性は十分にあります。