# Atuin daemon as Systemd user service

*October 10, 2024* — https://jade.wtf/tech-notes/atuin-daemon-user/

Tags: atuin, systemd

---


I use [Atuin](https://atuin.sh/) for friendly shell history and to sync it across my computers. 
It's great, it just [doesn't play well with ZFS](https://github.com/atuinsh/atuin/issues/952). 
As a workaround, Atuin recently added [a daemon mode](https://docs.atuin.sh/reference/daemon/) so there's one writer to handle 
sqlite instead of each shell command invocation hitting the same sqlite database. 

Currently there are no docs on how to set this up because daemon mode is experimental, 
so here's how I did it.

Create a systemd user unit in `~/.config/systemd/user/atuin.service`:
```
[Unit]
Description=Atuin daemon
[Service]
Type=simple
ExecStart=%h/.cargo/bin/atuin daemon
Restart=always
[Install]
WantedBy=default.target
``` 

Start it: `systemctl --user enable atuin.service --now`

And you should now see it running:
```
jda@tangent:~$ systemctl --user status atuin
● atuin.service - Atuin daemon
     Loaded: loaded (/home/jda/.config/systemd/user/atuin.service; enabled; preset: enabled)
     Active: active (running) since Thu 2024-10-10 23:32:27 MDT; 3min 48s ago
   Main PID: 585068 (atuin)
      Tasks: 4 (limit: 618587)
     Memory: 4.6M
        CPU: 90ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/atuin.service
             └─585068 /home/jda/.cargo/bin/atuin daemon

Oct 10 23:32:27 tangent systemd[4756]: Started atuin.service - Atuin daemon.
```

Now you need to tell Atuin to use the daemon by adding the following to `~/.config/atuin/config.toml`:
```
[daemon]
enabled = true
```

---

&copy; 2024 Jade Angrboða.
