Search code examples
servicesystemdsystemctlrhel8

systemctl Myservice.service not found


When I keep my Myservice.service file in /etc/systemd/system/Myservice.service. I get not-found error.

systemctl status Myservice
● Myservice.service
   Loaded: not-found (Reason: Unit Myservice.service not found.)
   Active: failed (Result: exit-code) since Thu 2020-08-27 11:04:58 EDT; 22min ago
 Main PID: 3539430 (code=exited, status=125)

But when I keep the same service file in /lib/systemd/system/Myservice.service. It works fine.

But why doesn't it work in the first scenario? why systemd not able to find file in first case. How can I debug this scenario with systemd.


Solution

  • I figured it out, In RHEL 8, My Myservice.service default selinux context is unconfined_u:object_r:admin_home_t:s0 under /etc/systemd/system/, I changed it to system_u:object_r:systemd_unit_file_t:s0. and That's it!