systemd 101

a pocket reference

Getting to know your system daemon

Create your user-created service files in:


The machine-created service files will go in:


more in-depth:

where do i put my systemd service file

what is the difference between systemd system and user services


a sample .service file, at /etc/systemd/system/hello.service:


Description=hello_env.js - making your environment variables rad

ExecStart=/usr/bin/node /home/ubuntu/hello_env.js


*common mistake - make sure to reference the same node or executable that your user has access to
( which node in this case )

Node JS walkthrough

Digital Ocean in-depth article

Admin with systemctl

refresh service files:

sudo systemctl daemon-reload

start app:

sudo systemctl start hello_env


sudo systemctl status hello_env

start at boot / don't start at boot:

sudo systemctl enable hello_env # / disable

list all services:

sudo systemctl list-unit-files

Debugging systemd:

investigating failed units

Logging with journalctl

Common commands:

journalctl -u [app name] # -u for "unit"

journalctl -f # -f for "follow" - show logs in real time
journalctl -n [number] # - specify number of lines to start
journalctl --disk-usage # total disk usage
journalctl --vacuum-size=1G # shrink oldest logs until specified size

see the DO guide for permanent settings:

Digital Ocean - comprehensive overview of journalctl

adjust to your timezone

sudo timedatectl list-timezones | grep [your region]
sudo timedatectl set-timezone [your region]

Leave a Reply

Your email address will not be published. Required fields are marked *