Operating System - Linux
1826489 Members
4021 Online
109692 Solutions
New Discussion

Re: how add scritps in startup

 
Abubakkar
Frequent Contributor

how add scritps in startup

Hi all,

how can i add the my scripts in startup. explain the steps.

 

Regards

Abu

1 REPLY 1
Matti_Kurkela
Honored Contributor

Re: how add scritps in startup

The exact requirements vary in different Linux distributions/versions.

 

In general, your scripts should follow the standards of the Linux Standards Base:

http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/tocsysinit.html

(see chapters 20.2 - 20.8 of the above)

 

The current version of LSB also has a standard installation and removal process for startup scripts.

 

For example, in RHEL, you should find instructions and an example script in /usr/share/doc/initscripts-<version>/sysvinitfiles.

(Looks like this has been true in older pre-Enterprise RedHat versions too, perhaps back to RHL 7.0, although the <version> part in the pathname will obviously be different in each version.)

 

If your system has the "chkconfig" command, you should read "man chkconfig": if your script complies with the requirements listed there, you can add your startup script by just copying it to /etc/init.d, and then running "chkconfig --add <name_of_script>".

 

Many newer Linux distributions (including RHEL 6) use a new "dependency-based" boot scheme, in which each script must declare the system services it depends on. This enables the system to boot up faster. As a result, the comment scheme described in this part of LSB is now a requirement, instead of just a recommendation:

http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/initscrcomconv.html

Also, your script should create an empty file in /var/lock/subsys/ if it starts up something that must be stopped at system shutdown. The name of the file should match the name of your script. (If this file does not exist, the stop function of your script won't be run, because the system assumes the service has already been stopped.)

MK