加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell – Elastic Beanstalk cron和部署权限

发布时间:2020-12-15 21:33:29 所属栏目:安全 来源:网络整理
导读:在部署到AWS Elastic Beanstalk期间,我想做两件事: 获取带有cron条目的文件并将此文件放在/etc/cron.d/中 更改单个目录中包含的shell脚本的文件权限,以便它们可以由cron执行 在我的.ebextensions文件夹中,我有以下内容: container_commands: 00fix_script_
在部署到AWS Elastic Beanstalk期间,我想做两件事:

>获取带有cron条目的文件并将此文件放在/etc/cron.d/中
>更改单个目录中包含的shell脚本的文件权限,以便它们可以由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触发的新shell脚本.

解决方法

container_commands:
00_fix_script_permissions:
command: "chmod u+x /opt/python/ondeck/app/scripts/*"

我是Linux和AWS Noob,但是我发现如上所述修改命令对我的用例来说是成功的.

/ opt / python / current / app / scripts / createadmin现在具有用户的执行权限

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读