1

I have a script in /etc/init.d that I'm trying to add echo statements to...but all of my changes seem to be ignored.

I'm guessing because the script itself is not actually run but that systemd is doing something behind the scenes to continue running the old version of the script. Is there a way to "load" these changes?

  • 1
    Don't guess - find out. What distro are you using? – countermode Feb 27 '17 at 20:22
  • See also: unix.stackexchange.com/a/233581/117549 – Jeff Schaller Feb 27 '17 at 21:22
  • Centos 7.2. I updated the question – wsaxton Feb 27 '17 at 21:47
  • Does a .service file also exist for your service, or just the sysv-style script? – mattdm Feb 27 '17 at 22:06
  • 1
    Answerers should not have to find the information that this is gogs buried down in the comments to an answer. This information should be in the question. And answerers might also enjoy unix.stackexchange.com/a/307321/5132 . – JdeBP Feb 27 '17 at 22:14
6

No, there's not a way for systemd to load the changes you made to files in /etc/init.d because systemd is largely ignoring the files anyway. See the gory details at How does systemd use /etc/init.d scripts?.

Consider asking a different question about the specific problem you are attempting to solve by editing /etc/init.d files.

I could guess that perhaps you are looking for ExecStartPre= or ExecStartPost=. Read man systemd.service for other directives that you can use in your systemd service unit files.

  • This was the answer. To troubleshoot, I just copied the script outside of /etc/init.d, modified it, and ran it manually. – wsaxton Feb 28 '17 at 3:06
0

You're on the right tracks. You will need to reload systemd's context using the following command:

sudo systemctl daemon-reload

It was a lot easier in the SysV days :)

  • No, the old init scripts are largely ignored as answer linked in Jeff's comment explains. Reloading any part of systemd won't make changes appear to be active. – Mark Stosberg Feb 27 '17 at 21:44
  • Unfortunately, that didn't work: [vagrant@gitserver ~]$ sudo head /etc/init.d/gogs #!/bin/sh echo "ZZ" [vagrant@gitserver ~]$ sudo systemctl daemon-reload [vagrant@gitserver ~]$ sudo systemctl start gogs [vagrant@gitserver ~]$ – wsaxton Feb 27 '17 at 21:46

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.