Doing jobs at specified times repeatedly using systemd.timer

suggest change

systemd provides a modern implementation of cron. To execute a script periodically, a service file and a timer file are needed. The service and timer files should be placed in /etc/systemd/system or /etc/systemd/user. The service file:

[Unit]
Description=my script or program does the very best and this is the description

[Service]
# type is important!
Type=simple
# program|script to call. Always use absolute paths.
# systemd does not run ExecStart through a shell, so use bash -c for redirection.
# Redirect stdout and stderr, because there is no terminal while the job is executed.
ExecStart=/bin/bash -c '/absolute/path/to/someCommand >>/path/to/output 2>/path/to/STDERRoutput'
# NO install section. That is handled by the timer facilities.
#[Install]
#WantedBy=multi-user.target

Next the timer file:

[Unit]
Description=my very first systemd timer
[Timer]
# Syntax for date/time specifications is  Y-m-d H:M:S 
# a * means "each", and a comma separated list of items can be given too
# *-*-* *,15,30,45:00  says every year, every month, every day, each hour,
# at minute 15,30,45 and zero seconds

OnCalendar=*-*-* *:01:00  
# this one runs each hour at one minute zero second e.g. 13:01:00

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents