* [final summary] h or script to kill old ftp processes
@ 2001-10-08 20:52 Oyanarte Portilho
0 siblings, 0 replies; only message in thread
From: Oyanarte Portilho @ 2001-10-08 20:52 UTC (permalink / raw)
To: tru64-unix-managers
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-10-08 20:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-08 20:52 [final summary] h or script to kill old ftp processes Oyanarte Portilho
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox