Sample Header Ad - 728x90

Start a service at boot time in systemd

0 votes
2 answers
1625 views
I have placed a systemd service file in usr/lib/systemd/system/testfile.service. Here is the service file: [Unit] Description=Test service [Service] Type=notify ExecStart=/bin/dd.sh ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=30s [Install] WantedBy=multi-user.target I tried to start the service at boot time these two ways: 1. Created a softlink for the file from /usr/lib/systemd/systemd to /etc/systemd/system/multi-user.target.wants (manually and by using systemctl enable command) and rebooted the system; testfile service started successfully at boot time. 2. Created a dependency in the existing running service file like After=testfile.service and Wants=testfile.service, then rebooted the system; testfile service started successfully. But when I place the file /usr/lib/systemd/system without using approaches 1 or 2 above, the service is not started. I feel that placing the service file in /usr/lib/systemd/system/ is enough for any service to start automatically, without creating the softlinks to wants directory or creating the dependency with the other services. Please let me know, how do I start a service at boot time which is present in the /usr/lib/systemd/system directory without using approaches 1 or 2 above? I have also created preset files in usr/lib/systemd/system-preset/ to disable and enable a few services, but it seems like those preset files were not executed: services which I have disabled in the preset file are still enabled after boot up. Please let me know how to debug this issue.
Asked by RAJESH DASARI (3 rep)
Aug 14, 2016, 05:51 AM
Last activity: Apr 12, 2023, 09:48 AM