This is possible with renaming of the scripts located in running configuration(rc) folders such as /etc/rc1.d, /etc/rc2.d etc. Each of these folders are corresponding to the scripts that will start in that run-level respectively. For example if you want to start some script in runlevel 1, then they should be kept in /etc/rc1.d folder so that when Linux OS is booting up these scripts are executed.
So how can I set priority to my scripts/services?
Just go in to one of the rc folders, you can see all the scripts which will start in that perticular runlevel.
If you observe those scripts, the name will start with either K(k for kill) or S(s for start) followed with numbers as shown below.
K09apache2
K15pulseaudio
K20acpi-support
K74bluetooth
README
S30killprocs
S70dns-clean
S70pppd-dns
S90single
So the scripts(services) which ever starts with K, will be killed in the numbering sequence and scripts which starts with S will start according to number followed by first character ie S.
So if you want to start S70dns-clean before all the scripts in this runlevel change the number to S01dns-clean. Thats it, you are done.
Before editing the script name:
K09apache2
K01pulseaudio
K20acpi-support
K74bluetooth
README
S30killprocs
S70dns-clean
S70pppd-dns
S90single
After edting the script name:
K09apache2
K01pulseaudio
K20acpi-support
K74bluetooth
README
S30killprocs
S01dns-clean
S70pppd-dns
S90single
So now the first script/service which start in this list is S01dns-clean
Please comment your thoughts on this. Please visit https://www.linuxnix.com for more linux admin stuff.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018