0

We're running a 3rd party TTY service on our servers, to support some thin clients manufactured by the 3rd party.

From time to time, connection to a thin client can get locked up. Procedure is to stop the TTY service, wait for connections to close, start the TTY service. Additionally on CentOS 4.x servers the command init q

Normally we do this manually like this, from root.

service axtty stop

Stop the service

netstat -d | grep axel

Run and monitor the netstat command until all connections are closed, ie. No lines containing axel.

service axtty start

Start the service

Is there a way to sum all that up in a single automated shell script (bash)?

Servers are CentOS 4.x or 6.x

1

#!/bin/sh

service axtty stop

while netstat -d | grep -q axel ; do
  sleep 1
done

service axtty start

NOTE: With GNU sleep, you could do sleep 0.1 or other floating point fraction of 1 second.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.