Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > ping inside of crontab fails to produce output

ping inside of crontab fails to produce output
Thread Tools
Mac Enthusiast
Join Date: Jan 2001
Location: Leesburg, Virginia
Status: Offline
Reply With Quote
Jan 17, 2005, 08:28 PM
 
Here is my root's crontab (see my other post on why I have that stuff in there):
Code:
* * * * * echo `date` -- `ping -c 1 xx.xx.xx.34 | sed -n -e 's/.*0\%.*/up/' -e 's/.*100\%.*/down/' -e "/up/p" -e "/down/p"` >> /var/log/uptime.log * * * * * ping xx.xx.xx.34 >> /var/log/ping.log
Interestingly, the first line fails to produce the desired output, and the second produces none at all. What am I missing?

Dominik Hoffmann
     
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Jan 18, 2005, 02:55 AM
 
Originally posted by DominikHoffmann:
Here is my root's crontab (see my other post on why I have that stuff in there):
Code:
* * * * * echo `date` -- `ping -c 1 xx.xx.xx.34 | sed -n -e 's/.*0\%.*/up/' -e 's/.*100\%.*/down/' -e "/up/p" -e "/down/p"` >> /var/log/uptime.log * * * * * ping xx.xx.xx.34 >> /var/log/ping.log
Interestingly, the first line fails to produce the desired output, and the second produces none at all. What am I missing?
crontab needs the full pathname to a command in order for it to work. It may be that crontab has /bin/ set somewhere as in its path but not /sbin/ so that is why echo and date work. Try this:
Code:
* * * * * /bin/echo `/bin/date` -- `/sbin/ping -c 1 xx.xx.xx.34 | /usr/bin/sed -n -e 's/.*0\%.*/up/' -e 's/.*100\%.*/down/' -e "/up/p" -e "/down/p"` >> /var/log/uptime.log
Note that ping is in /sbin/ and sed is in /usr/bin/. Whenever you use a command in crontab always try to use the full path to the command. You can check the path for different commands by typing 'which somecommand' in the Terminal and it will return the full path.
Code:
point:~ physicsadmin$ which echo /bin/echo point:~ physicsadmin$ which ping /sbin/ping point:~ physicsadmin$ which date /bin/date point:~ physicsadmin$ which sed /usr/bin/sed
On the topic of your other post... I am not so sure how useful the information you get from logging pings to an external host will be for VoIP. VoIP requires a really good connection from end to end through every single hop through every single router the TCP/IP packets make from client to client. The only part of this that you have any control over is your machines connection to the LAN. Once the packets leave your site there is nothing you can do about it. Once the packets leave your ISP there is nothing they can do about it either.
There is an RFC (name escapes me for the moment) about how routers that can handle VoIP can be configured for QoS to reduce the latency for VoIP protocol packets. More and more organizations are setting up their routers this way but it is not yet universal.
-DU-...etc...
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:08 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2