<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Systemd on Lloyd Rochester's Geek Blog</title><link>https://lloydroc.github.io/categories/systemd/</link><description>Recent content in Systemd on Lloyd Rochester's Geek Blog</description><generator>Hugo</generator><language>en</language><copyright>Copyright © 2025, Lloyd Rochester.</copyright><lastBuildDate>Sat, 08 Feb 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://lloydroc.github.io/categories/systemd/index.xml" rel="self" type="application/rss+xml"/><item><title>Timer example in systemd</title><link>https://lloydroc.github.io/post/unix/systemd-timer-example/</link><pubDate>Sat, 09 Jul 2022 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/unix/systemd-timer-example/</guid><description>&lt;h1 id="hahahugoshortcode95s0hbhb">Timer example in systemd&lt;/h1>
&lt;p>We can use &lt;code>systemd&lt;/code> instead of cron timers in Unix. Using &lt;code>systemd&lt;/code> timers is easy and provides numerous benefits over using Cron which are documented below. These timers more are complicated than cron, however, they are much more powerful.&lt;/p>
&lt;h1 id="creating-a-systemd-timer">Creating a &lt;code>systemd&lt;/code> timer&lt;/h1>
&lt;p>Let us look at the logical hierarchy of a timer on systemd and the files associated before we look at an example.&lt;/p>
&lt;h2 id="logical-requirements">Logical Requirements&lt;/h2>
&lt;p>To create a &lt;code>systemd&lt;/code> timer the following are required:&lt;/p></description></item><item><title>Systemd: Timers</title><link>https://lloydroc.github.io/post/unix/systemd_timers/</link><pubDate>Tue, 30 Jun 2020 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/unix/systemd_timers/</guid><description>&lt;h1 id="hahahugoshortcode98s0hbhb">Systemd: Timers&lt;/h1>
&lt;p>In the fourth post on how to create a service in &lt;code>systemd&lt;/code> we will create a timer that will run every minute sending messages to our example &lt;code>foo&lt;/code> service over a socket. We&amp;rsquo;re essentially creating a &lt;code>cron&lt;/code> job socket client.&lt;/p>
&lt;p>Previous posts:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://lloydroc.github.io/post/autotools/systemd-service-daemon-autotools/">Project Creation&lt;/a> of an autotools project and start/stop a daemon service.&lt;/li>
&lt;li>&lt;a href="https://lloydroc.github.io/post/unix/systemd_journal/">Journalling/Syslog&lt;/a> to enable logging, notify of state changes and accept reloads.&lt;/li>
&lt;li>&lt;a href="https://lloydroc.github.io/post/unix/systemd_sockets/">Socket&lt;/a> creation of a Unix Domain Socket for other processes to send messages to our service through remote procedure calls.&lt;/li>
&lt;/ul>
&lt;h1 id="what-the-example-will-do">What the example will do?&lt;/h1>
&lt;p>We already have a Unix Domain Socket created by &lt;code>systemd&lt;/code> that is listening on &lt;code>/var/log/foo.socket&lt;/code>. We also have a service called &lt;code>foo.service&lt;/code> that is listening to this socket . When messages are received on the socket the service will log them to the journal and syslog.&lt;/p></description></item><item><title>Systemd: A Service and a Socket</title><link>https://lloydroc.github.io/post/unix/systemd_sockets/</link><pubDate>Fri, 26 Jun 2020 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/unix/systemd_sockets/</guid><description>&lt;h1 id="hahahugoshortcode97s0hbhb">Systemd: A Service and a Socket&lt;/h1>
&lt;p>This is the third post on how to create a &lt;em>service&lt;/em> in &lt;code>systemd&lt;/code>. See the &lt;a href="https://lloydroc.github.io/post/autotools/systemd-service-daemon-autotools/">first post&lt;/a> to create a autotools project and start/stop a daemon service. Or the &lt;a href="https://lloydroc.github.io/post/unix/systemd_journal/">second post&lt;/a> to enable logging, notify of state changes and accept reloads. In this post we&amp;rsquo;ll create a Unix Domain Socket so that other processes can send messages to our service through remote procedure calls.&lt;/p>
&lt;p>The socket we will use in this post is a Unix Socket with domain &lt;code>AF_UNIX&lt;/code> of type &lt;code>SOCK_DGRAM&lt;/code>. This type of socket is well suited for example purposes and is also ideal for remote procedure call applications. It is limited to communication on the same host, not over the internet. Unix Domain sockets are always reliable and are guaranteed to be delivered in order without duplication. Since this example uses a datagram socket we can receive the full message on each reception. Typically, the size of a datagram socket is under 2048 bytes see &lt;a href="https://www.man7.org/linux/man-pages/man7/socket.7.html">socket(7)&lt;/a> and look for the &lt;code>SO_SNDBUF&lt;/code> option for more details on maximum datagram size.&lt;/p></description></item><item><title>Status, Reloading and Journalling in Systemd</title><link>https://lloydroc.github.io/post/unix/systemd_journal/</link><pubDate>Tue, 23 Jun 2020 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/unix/systemd_journal/</guid><description>&lt;h1 id="hahahugoshortcode96s0hbhb">Status, Reloading and Journalling in Systemd&lt;/h1>
&lt;p>This is the second post on how to create a &lt;em>service&lt;/em> in &lt;code>systemd&lt;/code>. In the &lt;a href="https://lloydroc.github.io/post/autotools/systemd-service-daemon-autotools/">first post&lt;/a> we created an &lt;em>autotools&lt;/em> project and were able to start, stop and get basic status on the service. In this post we&amp;rsquo;ll build on the &lt;em>autotools&lt;/em> project to add logging to &lt;code>syslog&lt;/code> and &lt;code>journald&lt;/code>. We will also give an example on how we could reload the service with a &lt;code>systemctl reload foo&lt;/code>. We will also use the &lt;a href="https://www.freedesktop.org/software/systemd/man/sd_notify.html#">sd_notify(3)&lt;/a> API to notify the service manager the status of what the service is doing.&lt;/p></description></item><item><title>Systemd and Autotools</title><link>https://lloydroc.github.io/post/autotools/systemd-service-daemon-autotools/</link><pubDate>Mon, 22 Jun 2020 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/autotools/systemd-service-daemon-autotools/</guid><description>&lt;h1 id="hahahugoshortcode8s0hbhb">Systemd and Autotools&lt;/h1>
&lt;p>This post starts a tutorial series on how to create a &lt;code>systemd&lt;/code> service in Linux. This first post is likely the hardest part as we create an &lt;a href="https://lloydroc.github.io/post/autotools/hello-world/">autotools&lt;/a> project with the source code and &lt;code>systemd&lt;/code> unit files. Having this setup in &lt;code>autotools&lt;/code> saves significant time installing unit files that &lt;code>systemd&lt;/code> requires, building our C code, installing, and uninstalling our program. If you can get through this first post the following posts should come easily.&lt;/p></description></item></channel></rss>