小编Rob*_*ent的帖子

为什么 crond 无法在 alpine linux 上运行非 root crontab?

我在 Alpine Linux 上运行非 root crontab 文件时遇到了麻烦。

我已经阅读了另外两个与 cron 相关的帖子,但我没有答案:

https://askubuntu.com/questions/23009/why-crontab-scripts-are-not-working

https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it

这是设置。

我的 crontab 看起来像这样:

PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/bin
SHELL=/bin/bash

* * * * * /opt/monitor/monitor.sh >> /var/log/monitor.log 2>&1
0 3 * * * /opt/monitor/monitor-log-clean.sh >> /var/log/monitor.log 2>&1
Run Code Online (Sandbox Code Playgroud)

我的 Dockerfile 现在有点乱,但这只是因为我一直在拼命尝试解决这个问题。它看起来像这样。简而言之,我为 crontab -e 添加 SUID 以作为其他用户工作,我创建我的用户,我导入我的 crontab 文件,然后我为我能想到的所有内容提供权限。

FROM alpine:3.5

# DEPENDENCY TO ALLOW USERS TO RUN crontab -e
RUN apk add --update busybox-suid

# I LIKE BASH
RUN apk --no-cache add bash bash-doc
RUN apk --no-cache add util-linux pciutils usbutils coreutils …
Run Code Online (Sandbox Code Playgroud)

linux cron docker alpine-linux

8
推荐指数
1
解决办法
9633
查看次数

标签 统计

alpine-linux ×1

cron ×1

docker ×1

linux ×1