Logwatchをsystemd timerで日次処理する

2014年6月現在、Arch LinuxではCronに代わってsystemd timerを使って定期実行をさせる方針のようです。
systemd/cron functionality (日本語) – ArchWiki
しかし、Logwatchをインストールすると、Cron(Cronie)が一緒にインストールされるし、ArchWikiもCronの解説が載っています。
Logwatch – ArchWiki
すでにLogrotateはsystemd timerで稼働させており、別にCronは動かしたくないので、Logwatchもsystemd timerで日次処理させようと思います。

設定は難しくありませんでした。

1. サービスファイル作成

/etc/systemd/system/logwatch.service

を下記のように作成。
【Unit】

Description=run logwatch
Wants=timer-daily.timer

【Service】

Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/usr/bin/logwatch --mailto (送信先メール)

※最後の行は自分がメールで受け取りたいために強制的にメール送信でLogwatchを実行しています。お好みで変更してください。
【Install】

WantedBy=timer-daily.target

2. サービス実行

systemctl enable logwatch.service

3. タイマー再起動

systemctl restart timer-daily.timer

以上です。

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください