Register
It is currently Wed Jul 23, 2014 7:49 pm

ping scripts


All times are UTC - 6 hours


Post new topic Reply to topic  [ 7 posts ] 
Author Message
 PostPosted: Fri Nov 19, 2010 2:12 pm   

Joined: Fri Nov 19, 2010 2:04 pm
Posts: 4
***Sorry moderator might want to move this to the request scripts section ***


I need 5 different scripts, each one pinging a different IP address. They need to start at boot and continuously ping the IP addresses. I have written these scripts but for some reason they aren't starting at boot time. Let me show you what I did.

Myscript looks like this:

ping -t 1 192.168.1.1

exit 0

I've tried it with and without the 'exit 0' I've also tried forwarding stdout to a log file. Nothing works.

I put the scripts in /etc/init.d/ (on an Ubuntu server) and I ran 'chmod 755 myscript'
I also ran 'update-rc.d -f myscript start 99 2 3 4 5 .'

Still nothing works. Please help. Tell me what I'm doing wrong


Last edited by dtigue on Fri Nov 19, 2010 2:20 pm, edited 1 time in total.

Top
 Profile  
 PostPosted: Fri Nov 19, 2010 2:19 pm   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
Have you tried reading the boot.log what the error message is?


Top
 Profile  
 PostPosted: Fri Nov 19, 2010 2:21 pm   

Joined: Fri Nov 19, 2010 2:04 pm
Posts: 4
my boot.log shows nothing, i've tried looking at it several times and everytime it is empty


Top
 Profile  
 PostPosted: Fri Nov 19, 2010 2:25 pm   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
In that case it either works without errors, or the init script isn't run at all.
The easiest way to check, would be to change your ping with an echo and check the bootlog again.


Top
 Profile  
 PostPosted: Fri Nov 19, 2010 4:52 pm   

Joined: Fri Nov 19, 2010 2:04 pm
Posts: 4
I set it up to log and still nothing. If I invoke the script manually it runs and the logs reflect that. But from a fresh boot I get nothing in the logs.


Top
 Profile  
 PostPosted: Mon Nov 22, 2010 8:24 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
How did you set it up to log?
Your system might need full path to the programs, so try using /bin/ping instead of just ping.
The very first line of your script should contain the path to the shell, i.e. something like
Code:
#!/bin/bash


Top
 Profile  
 PostPosted: Wed Dec 22, 2010 2:02 pm   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Something else to consider! You might need to fork that ping into the background with an ampersand (&):

#===============#
ping -t 1 192.168.1.1 &
#===============#

Are you looking for any output from those pings? If so, you might want to direct the output somewhere:

#===============#
ping -t 1 192.168.1.1 > /tmp/pinglog.txt &
#===============#

Using the & you can even launch all 5 of these pings from the same script! You might actually want to run something in cron to check periodically to see if your pings are running, and re-start them as needed.

Hope this helps!
-J


Top
 Profile YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP