I have a custom systemd service in CentOS 7 whose startup script lives under version control at /srv/etc/systemd/website.service:

After=syslog.target network.target

ExecStart=/opt/perl5/perls/perl-5.20.2/bin/hypnotoad /var/www/domains/<domain>/script/site.pl
ExecStop=/opt/perl5/perls/perl-5.20.2/bin/hypnotoad --stop /var/www/domains/<domain>/script/site.pl


If I run systemctl enable /srv/etc/systemd/website.service it creates the symlinks fine and I can run systemctl start website and the service comes up, but it complains about a missing [Install] section, which clearly isn't correct:

$ sudo systemctl enable /srv/etc/systemd/website.service 
Created symlink from /etc/systemd/system/website.service to /srv/etc/systemd/website.service.
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).

After rebooting, the service does not come up, and a systemctl start website returns Failed to start website.service: Unit not found. If I run systemctl daemon-reload, the start command works again.

However, if I copy the file into /etc/systemd/system and run systemctl enable website, everything works as expected and the service comes up immediately after reboot.

Is it actually possible to do what I'm trying to do, or do I just need to live with remembering to manually copy the systemd script from my Git repo if I make any changes?


You should check to see if the drive that the symlink is referring to is mounted at the time the services are starting.

  • Facepalm. It turns out that's exactly the issue, thanks! – VirtualWolf Dec 16 '18 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.