Skip to content

Instantly share code, notes, and snippets.

@amane-katagiri
Last active September 27, 2021 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amane-katagiri/cf1eaf18323b958afe8599cb4bb02f3f to your computer and use it in GitHub Desktop.
Save amane-katagiri/cf1eaf18323b958afe8599cb4bb02f3f to your computer and use it in GitHub Desktop.
busybox crond と non-root cronfile

/* この記事は、ライフ 人間と科学シリーズ(Plume)の閉鎖処理の一環として、投稿した情報の整理を行うために書かれた。 */

busybox crondでは、root所有ではないcronfileを黙ってスキップしてしまうらしい: dockerでBusyBox crondが動かない – numa blog

通常のcrondならエラーが出るっぽい: /etc/cron.dへ置くファイルにはownerとpermissionに制約があるっぽい - モヒカンメモ

$ echo '0 0 * * * root true' > root
$ docker run --rm -v $(pwd)/root:/etc/crontabs/root --init alpine timeout 3 \
  sh -c 'mount | grep /etc/crontabs/root; \
         ls -l /etc/crontabs/root; \
		     cat /etc/crontabs/root; crond -f -d 0'
/dev/sdc on /etc/crontabs/root type ext4 (rw,relatime,discard,errors=remount-ro,data=ordered)
-rw-r--r--    1 1000     1000            20 Sep 27 17:42 /etc/crontabs/root
0 0 * * * root true
crond: crond (busybox 1.32.1) started, log level 0
$ echo '0 0 * * * root true' > root
$ sudo chown root:root root
$ ls -l root
-rw-r--r-- 1 root root 20 Sep 28 02:42 root
$ docker run --rm -v $(pwd)/root:/etc/crontabs/root --init alpine timeout 3 \
  sh -c 'mount | grep /etc/crontabs/root; \
         ls -l /etc/crontabs/root; \
		     cat /etc/crontabs/root; crond -f -d 0'
/dev/sdc on /etc/crontabs/root type ext4 (rw,relatime,discard,errors=remount-ro,data=ordered)
-rw-r--r--    1 root     root            20 Sep 27 17:42 /etc/crontabs/root
0 0 * * * root true
crond: crond (busybox 1.32.1) started, log level 0
crond: user:root entry:0 0 * * * root true
100000000000000000000000000000000000000000000000000000000000
100000000000000000000000
11111111111111111111111111111111
111111111111
1111111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment