Running as a systemd Service (Linux)¶
This guide explains how to run TinyMonitor as a background service on Linux using systemd.
Quick Setup¶
The easiest way to install TinyMonitor as a service:
This will:
- Create
/etc/tinymonitor/directory (if needed) - Create the systemd service file
- Enable the service to start on boot
- Start the service
With Custom Configuration¶
Manual Setup¶
If you prefer manual control over the service configuration:
1. Create the service file¶
[Unit]
Description=TinyMonitor - Lightweight System Monitoring
Documentation=https://github.com/Gu1llaum-3/tinymonitor
After=network.target
[Service]
Type=simple
User=nobody
Group=nogroup
ExecStart=/usr/local/bin/tinymonitor -c /etc/tinymonitor/config.toml
Restart=on-failure
RestartSec=5
StandardOutput=journal
StandardError=journal
# Security hardening
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=read-only
PrivateTmp=true
ReadOnlyPaths=/
[Install]
WantedBy=multi-user.target
2. Reload systemd¶
3. Enable and start the service¶
Management Commands¶
Check status¶
Or use the built-in command:
View logs¶
# Live logs
sudo journalctl -u tinymonitor -f
# Last 100 lines
sudo journalctl -u tinymonitor -n 100
# Logs since last boot
sudo journalctl -u tinymonitor -b
# Logs from specific time
sudo journalctl -u tinymonitor --since "1 hour ago"
Restart service¶
After changing the configuration:
Stop service¶
Disable service¶
Prevent from starting on boot:
Service User¶
By default, the service runs as the nobody user for security. If you need to monitor paths that require specific permissions, you can change the user in the service file:
Then reload:
Uninstall Service¶
This removes the service but preserves your configuration files.
Troubleshooting¶
Service fails to start¶
Check the logs:
Common issues:
- Configuration error: Run
tinymonitor validate -c /etc/tinymonitor/config.toml - Permission denied: Check file permissions on config file
- Binary not found: Verify
which tinymonitorreturns/usr/local/bin/tinymonitor
Service starts but stops immediately¶
The configuration might be invalid. Test manually:
See Also¶
- tinymonitor service - Service command reference
- Running on macOS - macOS launchd setup
- Troubleshooting - Common issues