maltfield
(Michael Altfield)
1
我在 Discourse Docker 容器内的 /etc/cron.d/ 中添加了一个用于创建文件的模板,但无法让 cron 任务执行!相反,我在 Docker 容器的 syslog 中看到以下条目:
==> /var/log/syslog <==
Apr 22 11:45:01 osestaging1-discourse-ose CRON[30055]: Cannot make/remove an entry for the specified session
如何在 Discourse Docker 容器内定义并执行 cron 任务?
maltfield
(Michael Altfield)
2
这是 Docker 和 Debian 中的一个 bug 导致的结果。该问题之后已被修复,但似乎尚未针对 Discourse 的 Docker 镜像进行修复(尚未?)。
根据上述链接,我使用了以下模板文件来同时 [a] 创建 /etc/cron.d/ 文件,以及 [b] 修复 cron pam 模块中的 bug:
[root@osestaging1 discourse]# cat /var/discourse/templates/unattended-upgrades.template.yml run:
- file:
path: /etc/cron.d/unattended-upgrades
contents: |+
################################################################################
# 文件:/etc/cron.d/unattended-upgrades
# 版本:0.1
# 用途:在 systemd 不可用时运行 unattended-upgrades。更多信息请参阅
# * https://wiki.opensourceecology.org/wiki/Discourse
# * https://meta.discourse.org/t/does-discourse-container-use-unattended-upgrades/136296/3
# 作者:Michael Altfield <michael@opensourceecology.org>
# 创建日期:2020-03-23
# 更新日期:2020-03-23
################################################################################
20 04 * * * root /usr/bin/nice /usr/bin/unattended-upgrades --debug
- exec: /bin/echo -e "\n" >> /etc/cron.d/unattended-upgrades
# 修复 Docker cron bug https://stackoverflow.com/questions/43323754/cannot-make-remove-an-entry-for-the-specified-session-cron
- exec: /bin/sed --in-place=.`date "+%Y%m%d_%H%M%S"` 's%^\([^#]*\)\(session\s\+required\s\+pam_loginuid\.so\)$%\1#\2%' /etc/pam.d/cron
[root@osestaging1 discourse]#
不幸的是,我无法完全确定对 cron pam.d 模块进行此修改会带来哪些后果。但这看起来确实是上游公认的修复方案 :\
另请参阅:Does Discourse container use unattended-upgrades? - #9 by maltfield
system
(system)
关闭
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.