Thanks for your response.
I tried this:

#!/bin/bash
HOME_DIR=/home/stellarmate
MOUNT_NAME="iOptron CEM40"
LOG_DIR=$HOME_DIR/.local/share/kstars/logs

tail -F -n 1 $LOG_DIR/*/* |
grep --line-buffered 'Input/output error' |
while read ; do echo 'connection error, disconnecting in 5';
sleep 5; indi_setprop "$MOUNT_NAME.CONNECTION.DISCONNECT=On" ;
echo 'disconnected, reconnecting again in 5' ;
###rm -Rf $LOG_DIR/*
sleep 5; indi_setprop "$MOUNT_NAME.CONNECTION.CONNECT=On" ;
echo 'connected again, monitoring for more errors'; done

And it works fine detecting the error and re-connect :-)
But then it seems it still finds the same error in infinity (see log below).
I also tried to delete the log in the script but that doesn't help either.
Is there maybe a way to poll the mount's status with some indi_getprop command instead?
stellarmate@stellarmate:~ $ ./test.sh
connection error, disconnecting in 5
disconnected, reconnecting again in 5
connected again, monitoring for more errors
connection error, disconnecting in 5
disconnected, reconnecting again in 5
connected again, monitoring for more errors
connection error, disconnecting in 5
disconnected, reconnecting again in 5
^C


Read More...