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. サービスファイル作成
[bash]
/etc/systemd/system/logwatch.service
[/bash]
を下記のように作成。
【Unit】
[bash]
Description=run logwatch
Wants=timer-daily.timer
[/bash]
【Service】
[bash]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/usr/bin/logwatch –mailto (送信先メール)
[/bash]
※最後の行は自分がメールで受け取りたいために強制的にメール送信でLogwatchを実行しています。お好みで変更してください。
【Install】
[bash]
WantedBy=timer-daily.target
[/bash]

2. サービス実行
[bash]
systemctl enable logwatch.service
[/bash]

3. タイマー再起動
[bash]
systemctl restart timer-daily.timer
[/bash]

以上です。

コメントを残す

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

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