vbakaitis.net

Hi there! On this website I put things that I want to remember or things that might be useful for other people. If you want to get in touch with me, you can find me on twitter (@vbakaitis), or you can reach me via email. Same handle at gmail.

View My GitHub Profile

Other stuff:

Packing checklist
Wishlist
26 November 2018

Creating and scheduling systemd services

by Valentinas Bakaitis

Creating a service

#/lib/systemd/system/your_new.service
[Unit]
Description=Your service description
After=network.target 

[Service]
User=root
ExecStart=/path/to/binary/or/script/to/run.sh

[Install]
WantedBy=multi-user.target

Creating a timer

#/lib/systemd/system/your_new.timer
[Unit]
Description=Your timer description

[Timer]
OnCalendar=*-*-1 4:00:00
Unit=your_new.service

[Install]
WantedBy=timers.target

Reloading systemctl after modifying service files

systemctl daemon-reload

Testing (or running once) the service

systemctl start your_new.service

Enabling the timer

systemctl start date.timer

References:

  1. OnCalendar time format reference: https://www.freedesktop.org/software/systemd/man/systemd.time.html
tags: