LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-04-2010, 12:21 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 36
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.


Code:
[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
 
Old 02-04-2010, 12:33 AM   #2
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
Ping should not take too much of your local resources but how many pings you need to send? Keep pinging? It will definitely not recommended. Will slow up your network a bit.
You can run the script at boot by putting it rc.local file in /etc.
 
Old 02-04-2010, 01:01 AM   #3
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by linuxlover.chaitanya View Post
Ping should not take too much of your local resources but how many pings you need to send? Keep pinging? It will definitely not recommended. Will slow up your network a bit.
You can run the script at boot by putting it rc.local file in /etc.
Thank you very much chaitanya.That was indeed very helpful .I need to ping the machines continuously i m afraid it might slow down the network but i dont have any other option left with me .
 
Old 02-04-2010, 01:01 AM   #4
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
Hi pinga123,

If you want to just check weather the system is up, then you can send only 2 or 3 echo request packets through ping. This ping will not continue indefinitely.

Just place following script pinging.sh under /etc/rc.local

Code:
#!/bin/bash
ping -c 3 ip OR fully.quantified.domain.name;date > /home/username/temp
This will not consume much resources of your system..
You can see output in temp file of your home directory...

Last edited by vinaytp; 02-04-2010 at 01:03 AM.
 
Old 02-04-2010, 05:22 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Or, if you want to keep pinging indefinitely without unnecessary network load, insert a delay (here 30 secs) between groups of 3 pings
Code:
#!/bin/bash
while true
do
    ping -c 3 ip OR fully.quantified.domain.name;date > /home/username/temp
    sleep 30
done
 
Old 02-04-2010, 08:17 AM   #6
scheidel21
Senior Member
 
Registered: Feb 2003
Location: CT
Distribution: Debian 6-7, WIN 7-10, WIN SRV 03-12r2
Posts: 1,312

Rep: Reputation: 98
I would recommend the delay idea mentioned in the above bash script, you can continuously ping the machine to ensure it is up without continuously pinging. i.e. every minute 2 ping requests are sent, if they don't come back the machine is down. If they do come back you are still good to go.
 
Old 02-04-2010, 11:05 AM   #7
nodopro
Member
 
Registered: Oct 2008
Posts: 48

Rep: Reputation: 16
Ping,
I think you should mention about your purpose of pinging the machine continuously so these people can give you a suggestion or solution. I think putting sleep (delay time) is a good idea rather than ping after ping.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run script at startup? HOW? Stephan_Craft Linux - Newbie 2 09-03-2008 06:24 PM
Run Script on Startup aneesali Linux - Newbie 2 06-23-2007 01:55 PM
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
get a script to run on startup kram Debian 3 04-23-2005 02:23 PM
Run a script at startup iain.ross Linux - Newbie 8 08-27-2004 04:03 PM


All times are GMT -5. The time now is 06:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration