How to create a systemd service for your app
Updated 7/20/2026
A systemd service keeps your app running, restarts it if it stops and launches it automatically at boot. It is the correct way to run production processes on Linux.
1. Create the service file
Create /etc/systemd/system/my-app.service:
[Unit]
Description=My app
After=network.target
[Service]
User=www-data
WorkingDirectory=/var/www/app
ExecStart=/usr/bin/node server.js
Restart=always
Environment="NODE_ENV=production"
[Install]
WantedBy=multi-user.target
2. Start and enable
systemctl daemon-reload
systemctl enable --now my-app
3. Check the status
systemctl status my-app
journalctl -u my-app -f
See the service logs, useful for debugging, see managing logs.
Advantages over running manually
- Starts automatically after a server reboot.
- Restarts itself if the app crashes (
Restart=always). - Centralized logs through journalctl.
It works for Node, Python, Go apps or any process that must run continuously.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Dev environments
How to keep sessions running after disconnect with tmux
tmux keeps your terminal sessions alive even after you close SSH, ideal for long-running tasks.
Updated 7/20/2026Dev environmentsHow to install PHP (multiple versions) and Composer
Install the PHP version your project needs, along with Composer for package management.
Updated 7/20/2026Dev environmentsHow to manage environment variables and secrets
Keep passwords and keys out of your code, in environment variables, safely and correctly.
Updated 7/20/2026