From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <102653641821686.tru64-unix-managers.marc@archive.invalid> From: Oyanarte Portilho Date: Mon, 08 Oct 2001 20:52:07 +0000 To: tru64-unix-managers Subject: [final summary] h or script to kill old ftp processes X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=102653641821686 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