I have a script that I want to run at startup and on shutdown.
I have placed the file in /etc/init.d
and named it testscript.sh
Then I changed permissions sudo chmod 755 testscript.sh
Then I made link ln -s /etc/init.d/testscript.sh /etc/rc2.d/S99testscript.sh
So far so good, now the script runs at startup. I tried doing the same but making the links in rc0.d and rc6.d but that didn't work, the script still won't run at reboot/shutdown.
What am I doing wrong?
I'm running Ubuntu on putty client.
K99testscript.sh
.S
stands for start scripts, thus they are run when system starts,K
stands for kill scripts, thus they are run when system is shut down. Also I would recommend to createSystemd
unit files (if you are using new version of Ubuntu) rather thanSysV
scripts. – NarūnasK Mar 10 '17 at 21:45ln -s /nosuchpath ./broken-link; ls -l ./broken-link; rm ./broken-link
. – DopeGhoti Mar 10 '17 at 23:17rc
system that you are fiddling with since 2006. For over a decade it has only supported what you are playing with using two distinct sets of backwards-compatibility shims. If you are new to this stuff, and using an Ubuntu version from the past decade or so, then do not begin withrc
scripts at all. – JdeBP Mar 11 '17 at 09:23