[ubuntu-florida] Servers, clients, logs and shell arithmetics

j.e.aneiros jesus.aneiros at gmail.com
Thu Sep 16 14:59:16 BST 2010

Hello everyone,

Let's say that we have a client that connects to a server through the
network. The application's protocol specifies that the the client should
maintain a session and send a message (heartbeat) every 30 seconds to keep
the session alive. We have a log file with lines like the one below:

[2010-09-16 08:41:01.966] CLD -> HeartBeat-Sent

If we want to see if everything is OK we could take the last line of the
file and examine the timestamp against the local time of the machine. I
decide to take only the minutes and seconds and create a number like 1401
and compare that number against the local time in the same format. The line
of the shell script that do that part is below:

if [ $(( ${TIME_HERE} - ${TIME_THERE} )) -gt ${INTERVAL} ]

There is a potential runtime error in that block of code. Any idea what
could be wrong? Assume both machines are time synchronized to the
milliseconds resolution.

Have a good day.

J. E. Aneiros
GNU/Linux User #190716 en http://counter.li.org
perl -e '$_=pack(c5,0105,0107,0123,0132,(1<<3)+2);y[A-Z][N-ZA-M];print;'
PK fingerprint: 5179 917E 5B34 F073 E11A  AFB3 4CB3 5301 4A80 F674
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/ubuntu-us-fl/attachments/20100916/1412e955/attachment.htm 

More information about the Ubuntu-us-fl mailing list