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.