2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

supervisor+cron環境でログをdocker logsで確認する方法

Last updated at Posted at 2020-04-02

目的

コンテナ内のcrondログをdocker logs <コンテナID>で確認する。

必要ソフトウェア

  • docker
  • centos7
  • cron
  • supervisor

環境作成

Dockerfile
FROM centos:7
WORKDIR /root
RUN set -x && \
    yum install -y initscripts && \
    yum install -y rsyslog && \
    yum install -y logrotate && \
    yum install -y cronie && \
    yum install -y supervisor && \
    localedef -f UTF-8 -i ja_JP ja_JP
CMD ["/usr/bin/supervisord", "-n"]

crondログをpid1の標準出力にリダイレクト

/etc/cron.d/test
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
*/1 * * * * root echo "aaaaaaaaaaaa" > /proc/1/fd/1 2>/proc/1/fd/2
/etc/supervisord.d/test.ini
[program:crond]
command=crond -n
user=root
autostart=true
autorestart=true
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?