Shouldn't following command run myScript only at the runlevel 2. I noticed it executes at reboot too. I wanted to run it only and only at startup.
update-rc.d myScript start 01 2 . stop 01 0 1 6 .
Shouldn't following command run myScript only at the runlevel 2. I noticed it executes at reboot too. I wanted to run it only and only at startup.
update-rc.d myScript start 01 2 . stop 01 0 1 6 .
You should recognize the different runlevels inside myScript and do something different depending on the case. In runlevel 6 you should write some file to be discovered next time you reach runlevel 2. However, you may need to revise your design as this is a very strange requirement. What do you need to achieve ?
How is startup and reboot different? If the machine is dual-boot machine you can reboot from linux but then after that boot into windows for some time, say an hour, before again rebooting and boot linux. How is that different from just shutting down the machine for an hour? There is no way you can detect or predict at shutdown time what will happen after the reboot.
What I think you actually want to check is when your machine starts up booting linux your script must check how long time it was since the machine was shut down last time. If that is within a short period of time, say 5 minutes, you count it as a reboot. Otherwise you count it as a startup.
That's right. You need to check the first argument (start, stop, etc.) passed to your script to decide whats happening. It is explained in Debian Policy Manual '9.3.2 Writing the scripts' section.
Or alternatively you can run your script just by placing it in /etc/init.d/rc.local file or do not include any stop levels in your update-rc.d.