How I configured Arch Linux to run my stuff

Agreed, this article is mostly written for future me, when I forgot all about how systemd works.

I have a raspberry pi at home that I want to run a couple of my hobby projects on. I have written a simple reverse proxy server that redirects requests to the appropriate hobby project that is listening on another port. I am running Arch Linux, Arch Linux is using systemd, and I always forget how to tell systemd to start a service.

So how do I start a service?!

All user defined services are located at /etc/systemd/system. In here you can dump a .service file specifying how to run a given service. The file will look like this:

Description=Some human readable description

Once this is in place, the service will start automatically the system boots. If you are impatient, you can start it manually with (as root)

$ systemctl start <unit>

where unit is the name of the .service file. This will of course fail silently if you, for instance, forgot to set the executable bit. To see any output of the service you can ask journald about what has happened

journalctl -u <unit>

But how do I run a service periodically?!

Since systemd completely ditched cron, you need to do this another way; the easiest of course being the systemd way. You basically need to create a .service file for your periodic job and pair that up with a corresponding .timer file. The following will run the service once a day..

Description=Some human readable description

Hopefully I’ve just saved future me for a lot searching the internet and rtfm.