Turn a script or program into a managed service that starts at boot and restarts on failure. 16.11.2025 | reading time: 2 min Want a script to run like a proper background service? In this short guide the administrator will create a unit file, enable it to start at boot and inspect logs so the service behaves like any other managed daemon. Practical example Create a simple service called hello that runs a Python script; save the unit at /etc/systemd/system/hello.service: ``` [Unit] Description=Hello Service After=network.target [Service] Type=simple ExecStart=/usr/bin/python3 /opt/hello.py Restart=on-failure User=nobody [Install] WantedBy=multi-user.target ``` Then reload systemd, enable and start the service: ``` sudo systemctl daemon-reload sudo systemctl enable --now hello.service sudo systemctl status hello.service ``` Sample status output might look like: ``` ● hello.service - Hello Service Loaded: loaded (/etc/systemd/system/hello.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2025-11-11 10:00:00 UTC; 5s ago ``` Tuning behavior Control how systemd runs the process with options such as Type=simple or Type=forking, Restart=on-failure, User= and WorkingDirectory=; use After= or Requires= to order startup and create templated units like myjob@.service for per-instance services, and replace ExecStart= to run pre- and post-commands with ExecStartPre= and ExecStartPost=. Observe and debug Inspect runtime state and logs with `systemctl status` and `journalctl -u`, run one-off services with `systemd-run`, and profile boot time with `systemd-analyze` so he can find ordering or dependency delays and fix race conditions quickly. Where this goes next Once the unit works, consider adding a systemd timer instead of cron for schedule-based jobs, split complex setups into separate units with clear dependencies, and package unit files with configuration management so deployments stay reproducible. Final thought Writing a custom systemd service turns ad-hoc scripts into robust, observable daemons; keep experimenting, read the unit manpages for advanced options, and consider formalizing skills with CompTIA Linux+ or LPIC-1 preparation at bitsandbytes.academy to deepen practical mastery of Linux. Join Bits & Bytes Academy First class LINUX exam preparation. setup boot-process processes scripting troubleshooting