🔧

systemd Service Generator

Generate production-ready systemd service unit files for Linux. Configure service startup, restart policies, dependencies, and security settings.

Service Template

Basic Information

Execution

User & Permissions

Restart Policy

Environment Variables

Dependencies

network.target

Security Settings

Resource Limits

Generated Service File

[Unit]
Description=My Application Service
After=network.target

[Service]
Type=simple
User=myapp
Group=myapp
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/myapp
Restart=on-failure
RestartSec=5
KillMode=mixed
TimeoutStartSec=90
TimeoutStopSec=30
ProtectSystem=full

[Install]
WantedBy=multi-user.target

Features

Multiple Templates

Pre-configured templates for web apps, API servers, workers, databases, and Docker containers

Security Hardening

Built-in security settings including PrivateTmp, ProtectSystem, and NoNewPrivileges

Full Configuration

Configure restart policies, dependencies, environment variables, and resource limits

How to Install Your Service

📝 Installation Steps

  1. 1. Download the generated service file
  2. 2. Copy to systemd directory: sudo cp yourservice.service /etc/systemd/system/
  3. 3. Set proper permissions: sudo chmod 644 /etc/systemd/system/yourservice.service
  4. 4. Reload systemd daemon: sudo systemctl daemon-reload
  5. 5. Enable service on boot: sudo systemctl enable yourservice
  6. 6. Start the service: sudo systemctl start yourservice
  7. 7. Check status: sudo systemctl status yourservice

🔍 Useful Commands

View logs: sudo journalctl -u yourservice -f
Restart service: sudo systemctl restart yourservice
Stop service: sudo systemctl stop yourservice
Disable auto-start: sudo systemctl disable yourservice

Best Practices

1

Use Dedicated User

Run services as dedicated non-root users with minimal permissions for better security.

2

Configure Restart Policy

Set appropriate restart policy (on-failure, always) to ensure service availability.

3

Set Resource Limits

Define memory and CPU limits to prevent runaway processes from affecting the system.

4

Enable Security Features

Use PrivateTmp, ProtectSystem, and NoNewPrivileges to harden service security.

5

Monitor Service Logs

Regularly check service logs using journalctl to catch issues early.

6

Define Dependencies

Specify After and Requires directives to ensure services start in the correct order.

7

Test Before Enabling

Always test with systemctl start before enabling auto-start on boot.

Service Type Explanations

simple

Default type. systemd considers the service started immediately after the main process is launched.

forking

For processes that fork and the parent exits. Common for traditional daemons.

oneshot

For short-lived processes that execute once and exit. Often used with RemainAfterExit.

notify

Service sends a notification when it's ready. Requires application support for sd_notify.

dbus

Service is considered started when it acquires a D-Bus name.

idle

Delays execution until all jobs are finished. Used to avoid output mixing with status information.

Template Use Cases

📦

Basic

General-purpose service template suitable for most applications with standard configuration.

🌐

Web App

For Node.js, Python, or Ruby web applications with environment variables and web server dependencies.

🔌

API Server

Optimized for REST/GraphQL APIs with database dependencies and resource limits.

⚙️

Worker

Background job processors, queue workers, and scheduled tasks with always-restart policy.

💾

Database

Custom database services with forking type, extended timeouts, and high resource limits.

🐳

Docker

Manage Docker containers as systemd services with automatic container management.