简体   繁体   中英

How to start init.d script on bootup in embedded linux. I dont have update-rc.d. Is there any other way to start init.d script on linux boot?

I am have a Linux board on which I have added one init script under /etc/init.d/ directory. I can start,stop,restart service using script manually. For Debian we do use "update-rc.d" to execute this script at boot time. But i don't have this command, How then can i execute the script at boot time? Is there any alternate way to do this?

You can edit the /etc/inittab file.

Also, there are 2 other alternatives to update-rc.d:

  1. Rcconf - Rcconf allows you to control which services are started when the system boots up or reboots. It displays a menu of all the services which could be started at boot. The ones that are configured to do so are marked and you can toggle individual services on and off.This tool configures system services in connection with system runlevels. It turns on/off services using the scripts in /etc/init.d/.

  2. File-rc - Alternative boot mechanism using a single configuration file This package provides an alternative mechanism to boot the system, to shut it down and to change runlevels. The /etc/rc?.d/* links will be converted into one single configuration file /etc/runlevel.conf instead, which is easier to administrate than symlinks, and is also more flexible. The package will automatically convert your existing symlinks into the file method on installation, and convert the file back into symlinks on removal.

inittab has some other uses. The main use is creating "unkillable" service, that will be restarted every time it dies.

If you need just usual service, you can just create symlinks manually. Example from apache, like very typical service with default runlevels.

# ls -la /etc/rc*.d/*apache2
lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc0.d/K02apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc1.d/K02apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc2.d/S02apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc3.d/S02apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc4.d/S02apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc5.d/S02apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc6.d/K02apache2 -> ../init.d/apache2

So it should be killed at runlevels 0 1 6 and started on runlevels 2 3 4 5.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM