I create symlink in init.d directory: ln -s /myservice.jar /etc/init.d/myservice.

After reboot system symlink is replaced with regular file.

ls -l /etc/init.d/myservice output before reboot:

lrwxrwxrwx 1 root root 30 Mar 31 12:34 /etc/init.d/myservice -> /myservice.jar

After reboot:

-rwxrwxrwx 1 root root 41912304 Mar 31 12:40 /etc/init.d/myservice.jar

Why is this happening?

upd. On the server is used ISPmanager, can this be a problem?

  • I can't answer that because I've not got experience with it, but if you want to stop it you might want to make the file immutable. chattr +i filename will make a file unwritable even by root until chattr -i is used to remove the bit. – Wyatt8740 Mar 31 '17 at 13:40
  • Which version of CentOS are you using? – roaima Apr 2 '17 at 21:42

what happens, if you execute

$ java -jar /etc/init.d/myservice

Does it work as expected? And does it happen to replace myservice with myservice.jar at that very moment of running the java -jar command? If so, then we have a clue about the mysterious behaviour you described.

Jar files are designed to be portable, while symlinks surely are not, so I'd expect this behaviour to be a blunt result of some auto-correction on Java's side to eagerly satisfy its classpath needs.

Regards, Micha

| improve this answer | |
  • Spring boot create executable .jar file that, when launched by symlink, starts as a service. Before reboot system everything works fine – Nick Apr 3 '17 at 11:14

Will service myservice start start you application ? (service myservice.jar start)

more important, will service myservice stop stop you application ?

file in /etc/init.d are services files.

  1. They are supposed to be called with start|stop|status|restart as only argument. (| stand for or)

  2. They are supposed to be linked from /etc/rcX.d where X in run level (0 to 6).

  3. furthemore, some indication tell when to start them (before or after filesystems are up ? before or after network is up ? database ? webserver ? ), so rcinit will parse them.

| improve this answer | |
  • In a traditional init subsystem a file in init.d is the definitive one, and the rc.d S* and K* files are the symlinks. i still haven't got my head around the mess that systemd has made of that all. (Sometimes the shims work but other times they don't.) – roaima Apr 2 '17 at 20:41

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.