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:
- Created a softlink for the file from
/usr/lib/systemd/systemdto/etc/systemd/system/multi-user.target.wants(manually and by usingsystemctl enablecommand) and rebooted the system;testfileservice started successfully at boot time. - Created a dependency in the existing running service file like
After=testfile.serviceandWants=testfile.service, then rebooted the system;testfileservice 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.