avatar

Hi, I'm Mayeu

I mostly do computering, tea, and travelling

Disponible en français


Running Systemd commands on remote host from your local host

While I was reading the pretty awesome Archlinux wiki for something completely different, I found out that one can launch any systemctl command to a remote host via the --host (or -H) flag.

So let say you want to check the cron process on a server named kitten:

1
2
3
4
5
6
7
8
9
$ systemctl -H root@kitten status cron
● cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-07-28 11:36:37 CST; 2 months 25 days ago
     Docs: man:cron(8)
 Main PID: 1045
    Tasks: 1 (limit: 4643)
   CGroup: /system.slice/cron.service
           └─1045 /usr/sbin/cron -f

Nice right? Under the hood this use SSH so you must have access to the host. And you can, of course, use any systemctl command, not just status ;)

Have fun 👋


Did you enjoy this article? Don't want to miss any new posts and get exclusive content? Then hop into my newsletter :)

You can also contact me directly via email: m [-at-] mayeu [-dot-] me