1
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 5 years have passed since last update.

プロジェクトごとにcronファイルを分けて管理する

Posted at

ひとつのサーバに複数のプロジェクトのcron設定をcrontab -eで管理するのを辞めたいので/etc/cron.d配下にcronファイルを設置するようにする。

cronファイルの設置方法

cronファイルを/etc/cron.dに設置します。

# touch /etc/cron.d/sample

パーミッションを644に変更します。

# chmod 644 /etc/cron.d/sample

所有者をrootに変更します。

# chown root:root /etc/cron.d/sample

設置したcronファイルの内容はこのようになります。

/etc/cron.d/sample
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# * * * * * [user] [command]
0 * * * * root /path/to/hoge

最後にログ/var/log/cronで正常に動いているかを確認します。

# tail -f /var/log/cron
Oct  3 00:00:00 localhost CROND[9999]: (root) CMD (/path/to/hoge)
1
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
1
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?