I want to run a script on poweroff in Ubuntu.so I made a script, placed it in init.d & made a softlink in rc0.d with name S36xyz.my script is working perfectly when I run it in terminal. so there is not any problem with script.But my script is executing at poweron rather than poweroff. I dont know what I am doing wrong. Can any one help me with this.
Softlink in rc0.d is working on poweron rather than shutdown
linux;ubuntu;runlevel
You have to make a softlink with the name K36xyz. The K at the start stands for Kill. You used S which stands for StartAdditionally, custom is to test $1 within the script, as the Sxy links/scripts are invoked with start as a parameter and the Kxy ones with stop. That way you can use the same script for starting and stopping a service if you make the appropriate links.You can only do so much in such a script. E.g. postfix on my Ubuntu 12.04 system is being shut down (/etc/rc0.d/K20postfix) before K36xyz, so sending mail from such a script probably won't work as expected.