From: Oyanarte Portilho <portilho () fis ! unb ! br>
To: tru64-unix-managers
Subject: [final summary] h or script to kill old ftp processes
Date: Mon, 08 Oct 2001 20:52:07 +0000 [thread overview]
Message-ID: <102653641821686.tru64-unix-managers.marc@archive.invalid> (raw)
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
reply other threads:[~2001-10-08 20:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox