CodexBloom - Programming Q&A Platform

implementing `systemctl` enabling a service to start at boot on CentOS 8

👀 Views: 39 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-03
systemd centos services bash

I'm stuck trying to I just started working with I'm converting an old project and I've looked through the documentation and I'm still confused about I am having trouble enabling a custom service to start at boot on my CentOS 8 machine....... I created a service file located at `/etc/systemd/system/my_service.service` with the following content: ```ini [Unit] Description=My Custom Service After=network.target [Service] Type=simple ExecStart=/usr/bin/my_script.sh Restart=on-failure [Install] WantedBy=multi-user.target ``` I then executed `sudo systemctl enable my_service.service` to enable it, and I received the following output: ``` Created symlink /etc/systemd/system/multi-user.target.wants/my_service.service → /etc/systemd/system/my_service.service. ``` However, after rebooting the server, the service does not seem to start automatically. I checked the status using `systemctl status my_service.service`, and it says: ``` ● my_service.service - My Custom Service Loaded: loaded (/etc/systemd/system/my_service.service; enabled; vendor preset: disabled) Active: inactive (dead) ``` I tried adding `ExecStartPre=/usr/bin/sleep 5` to the `[Service]` section to see if it was a timing scenario, but it didn't help. I also inspected the logs using `journalctl -u my_service.service`, which shows no entries indicating that it even attempted to start after the reboot. I made sure that `my_script.sh` is executable and runs without scenario when called manually. What could be causing this service not to start at boot, and how can I troubleshoot this further? I'm working on a web app that needs to handle this. How would you solve this? This is my first time working with Bash 3.9. Could someone point me to the right documentation? Any ideas what could be causing this?