Systemd.timer
lastmod 2022-02-24created 2022-02-243 edits
Simple example
Create a script file to run as a scheduled job. /root/timer.sh:
Create the job service that actually runs:
/etc/systemd/system/myjob.service:
Create a timer that runs the myjob service.
/etc/systemd/system/myjob.timer:
[Unit]
Description=myjob timer
[Timer]
OnBootSec=1min
OnCalendar=*:*:1
Unit=myjob.service
[Install]
WantedBy=multi-user.target
Enable the timer so it runs at boot.
Start the timer.
Check that the timer works properly.
It works if a log line is written every minute, like below.
Mon Apr 27 14:46:44 KST 2020
Mon Apr 27 14:47:44 KST 2020
Mon Apr 27 14:48:44 KST 2020
Mon Apr 27 14:49:44 KST 2020
Mon Apr 27 14:50:44 KST 2020