Hits : 1264
Last Edit: 22.07.2017 13.20

systemd/Timers


a mini tutorial on systemd timers



Read this blog post: https://balaskas.gr/blog/2015/07/17/timers-in-systemd/

Clean Up Journal

List Timers


~> sudo systemctl list-timers


Create the Service


~> sudo  vim /etc/systemd/system/cleanjournal.service


[Unit]
Description=Clean Up Journal Log database

[Service]
Type=simple
ExecStart=/usr/bin/journalctl --vacuum-time=7d


Create the timer


~> sudo  vim /etc/systemd/system/cleanjournal.timer


[Unit]
Description=Clean Up Journal Log Database every week

[Timer]
OnCalendar=weekly
Persistent=true

[Install]
WantedBy=multi-user.target

List New Timer/Service


~> sudo  systemctl list-unit-files|grep -i cleanjournal
cleanjournal.service                                             static         
cleanjournal.timer                                               disabled


Start Service


~> sudo  systemctl start cleanjournal.service

Start Timer


~> sudo systemctl start cleanjournal.timer

Enable Timer


~> sudo systemctl enable cleanjournal.timer


List enabled timer


~> sudo systemctl list-timers | grep cleanjournal
Mon 2017-07-24 00:00:00 EEST  1 day 10h left n/a                           n/a       cleanjournal.timer           cleanjournal.service