Hi Gurus,
Thanks to Joerg Bruehe for calling my attention to potential problems
in the script I summarized two days ago. Since the ps axu|grep ftp
output (in Tru64 Unix 5.0a) contains lines that start with "ftp" and
end with "(ftpd)" it is safer to ask grep to find these two matches,
in order to prevent any confusion with other processes (maybe from some
user who has the string "ftp" in his/her username or in other instances)
that should not be killed. So, I have substituted
grep ftp
by
grep '^ftp.*ftpd)$'
and the script final (?) form is the following:
............
#!/bin/ksh
#
for PROID in `ps aux | grep '^ftp.*ftpd)$' | grep -v grep | awk '{print $2}'`
do
PHOUR=`ps -fp ${PROID} | awk '{print $5}'|cut -d":" -f1|cut -d "E" -f2`
CHOUR=`date +"%H"`
LIMIT=`expr 8`
if [ ${CHOUR} -lt ${PHOUR} ]
then
ELAPSED=`expr 24 - ${PHOUR} + ${CHOUR}`
else
ELAPSED=`expr ${CHOUR} - ${PHOUR}`
fi
if [ ${ELAPSED} -gt ${LIMIT} ]
then
kill -9 ${PROID}
fi
done
#
................
Best wishes,
Oyanarte Portilho
Institute of Physics
University of Brasilia, Brazil
Received on Mon Oct 08 2001 - 20:50:46 NZDT