Need to run script at startup.

Hi guys ,

I Need to run a specific command (pinging a particular machine).
Which need to run every time i reboot the server till the time it shut down.
What is the preferred way of doing this.

Will it impact my system performance.

My Operating system is as below.

[root@XYZ~]# lsb_release -a
LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: OracleVMserver
Description:    Oracle VM server release 2.2.0
Release:        2.2.0
Codename:       n/a
[root@XYZ~]# uname -r
2.6.18-128.2.1.4.9.el5xen

Your system startup scripts should live in /etc/rc.d. Depending on your distribution, you should find a script rc.local there, which will get executed after all other startup scripts are done. Put your stuff in there.

Performance: well, it will extend the startup time by the runtime of your script, obviously. If you are concerned about that, run your script in the background...

Best, Andre.

being new to the technology kindly correct if i m wrong.
does running the script means putting & at the end of script name.

Running the script: you can simply put the script (path + name + arguments) on a single line. Your local.rc could look like this

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

/home/pinga/bin/startup_1.sh -parameter value

If you do that, the script will be called during boot (at the end actually), and your system startup will only be completed once your own startup script has finished (rc.local will wait for the script to complete before continuing).

If startup_1.sh takes a long time, then you may want to run it in the background - *that* is when you add the '&', like

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

/home/pinga/bin/startup_1.sh -parameter value &

Then the rc.local script will just start the script, and cotinue on w/o waiting for it to finish. But that also means that, once your system is up, you can't rely on that your script has done all its work.

Best, Andre.