<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>automation &amp;mdash; Arjen Wiersma</title>
    <link>https://www.arjenwiersma.nl/tag:automation</link>
    <description>A blog on Emacs, self-hosting, programming and other nerdy things</description>
    <pubDate>Sun, 10 May 2026 11:46:18 +0000</pubDate>
    <item>
      <title>Automatically storing my notes</title>
      <link>https://www.arjenwiersma.nl/automatically-storing-my-notes</link>
      <description>&lt;![CDATA[I tried out obsidian a while back, and while I did not particularly like the experience as a whole, one thing I did like was the git integration. Back in my Emacs I have to manually call up magit to do the commits. So I decided to solve it in &#34;The Linux way (tm)&#34;; a small program that does the trick.&#xA;&#xA;Normally I would use crontab for this job, but modern Linux systems come equipped with something more powerful. systemd is on pretty much every linux system now, if you like it or not. It provides a framework of managing services and tasks.&#xA;&#xA;The script&#xA;&#xA;First we need a script that does what we need it to do. I put it in my ~/.local/bin directory as store-notebook.sh. All it does is to go into my notes directory, does a git add with a commit, and only if there are commits, a pull and a push.&#xA;&#xA;!/usr/bin/env sh&#xA;&#xA;NOTEBOOKPATH=~/Nextcloud/obsidian&#xA;&#xA;cd $NOTEBOOKPATH &amp;&amp; &#xA;  git add . &amp;&amp; &#xA;  git commit -am &#34;Auto commit from laptop&#34; &amp;&amp; &#xA;  git pull -r origin main &amp;&amp; &#xA;  git push origin main&#xA;&#xA;The service&#xA;&#xA;Then we want a service to run this script. User files are stored in your user systemd directory. Mine is: /home/arjen/.config/systemd/user/.&#xA;&#xA;I created the file store-notebook.service into that directory.&#xA;&#xA;[Unit]&#xA;Description=A job to push notebook changes to git&#xA;&#xA;[Service]&#xA;Type=simple&#xA;ExecStart=/home/arjen/.local/bin/store-notebook.sh&#xA;&#xA;[Install]&#xA;WantedBy=default.target&#xA;&#xA;The timer&#xA;&#xA;Just having the service does nothing, as it is not run. You can run it manually, but that defeats the purpose. The next piece is to configure the time, store-notebook.timer. This is basically the old-skool cron job.&#xA;&#xA;[Unit]&#xA;Description=Store notebook every 10 minutes&#xA;RefuseManualStart=no  # Allow manual starts&#xA;RefuseManualStop=no   # Allow manual stops&#xA;&#xA;[Timer]&#xA;Execute job if it missed a run due to machine being off&#xA;Persistent=true&#xA;Run 120 seconds after boot for the first time&#xA;OnBootSec=120&#xA;Run every 10 minute thereafter&#xA;OnUnitActiveSec=600&#xA;File describing job to execute&#xA;Unit=store-notebook.service&#xA;&#xA;[Install]&#xA;WantedBy=timers.target&#xA;&#xA;There are some comments in the file that allow you to configure timing of the task.&#xA;&#xA;Then, all that is left is to enable everything.&#xA;&#xA;chmod +x store-notebook.sh&#xA;systemctl --user enable store-notebook.service&#xA;systemctl --user start store-notebook.service&#xA;systemctl --user enable store-notebook.timer&#xA;systemctl --user start store-notebook.timer&#xA;&#xA;Checking all the things&#xA;&#xA;You can verify everything is running by calling the status on the service/timer or listing the timers.&#xA;&#xA;systemctl --user status store-notebook.service&#xA;systemctl --user status store-notebook.timer&#xA;systemctl --user list-timers --all&#xA;&#xA;Tags: #automation #orgmode #emacs]]&gt;</description>
      <content:encoded><![CDATA[<p>I tried out obsidian a while back, and while I did not particularly like the experience as a whole, one thing I did like was the <code>git</code> integration. Back in my Emacs I have to manually call up <code>magit</code> to do the commits. So I decided to solve it in “The Linux way ™”; a small program that does the trick.</p>

<p>Normally I would use <code>crontab</code> for this job, but modern Linux systems come equipped with something more powerful. <code>systemd</code> is on pretty much every linux system now, if you like it or not. It provides a framework of managing services and tasks.</p>

<h2 id="the-script">The script</h2>

<p>First we need a script that does what we need it to do. I put it in my <code>~/.local/bin</code> directory as <code>store-notebook.sh</code>. All it does is to go into my notes directory, does a <code>git add</code> with a <code>commit</code>, and only if there are commits, a <code>pull</code> and a <code>push</code>.</p>

<pre><code>#!/usr/bin/env sh

NOTEBOOK_PATH=~/Nextcloud/obsidian

cd $NOTEBOOK_PATH &amp;&amp; 
  git add . &amp;&amp; 
  git commit -am &#34;Auto commit from laptop&#34; &amp;&amp; 
  git pull -r origin main &amp;&amp; 
  git push origin main
</code></pre>

<h2 id="the-service">The service</h2>

<p>Then we want a service to run this script. User files are stored in your user systemd directory. Mine is: <code>/home/arjen/.config/systemd/user/</code>.</p>

<p>I created the file <code>store-notebook.service</code> into that directory.</p>

<pre><code>[Unit]
Description=A job to push notebook changes to git

[Service]
Type=simple
ExecStart=/home/arjen/.local/bin/store-notebook.sh

[Install]
WantedBy=default.target
</code></pre>

<h2 id="the-timer">The timer</h2>

<p>Just having the service does nothing, as it is not run. You can run it manually, but that defeats the purpose. The next piece is to configure the time, <code>store-notebook.timer</code>. This is basically the old-skool cron job.</p>

<pre><code>[Unit]
Description=Store notebook every 10 minutes
RefuseManualStart=no  # Allow manual starts
RefuseManualStop=no   # Allow manual stops

[Timer]
#Execute job if it missed a run due to machine being off
Persistent=true
#Run 120 seconds after boot for the first time
OnBootSec=120
#Run every 10 minute thereafter
OnUnitActiveSec=600
#File describing job to execute
Unit=store-notebook.service

[Install]
WantedBy=timers.target
</code></pre>

<p>There are some comments in the file that allow you to configure timing of the task.</p>

<p>Then, all that is left is to enable everything.</p>

<pre><code>chmod +x store-notebook.sh
systemctl --user enable store-notebook.service
systemctl --user start store-notebook.service
systemctl --user enable store-notebook.timer
systemctl --user start store-notebook.timer
</code></pre>

<h2 id="checking-all-the-things">Checking all the things</h2>

<p>You can verify everything is running by calling the status on the service/timer or listing the timers.</p>

<pre><code>systemctl --user status store-notebook.service
systemctl --user status store-notebook.timer
systemctl --user list-timers --all
</code></pre>

<p>Tags: <a href="https://www.arjenwiersma.nl/tag:automation" class="hashtag"><span>#</span><span class="p-category">automation</span></a> <a href="https://www.arjenwiersma.nl/tag:orgmode" class="hashtag"><span>#</span><span class="p-category">orgmode</span></a> <a href="https://www.arjenwiersma.nl/tag:emacs" class="hashtag"><span>#</span><span class="p-category">emacs</span></a></p>
]]></content:encoded>
      <guid>https://www.arjenwiersma.nl/automatically-storing-my-notes</guid>
      <pubDate>Sat, 07 Feb 2026 08:04:11 +0000</pubDate>
    </item>
  </channel>
</rss>