tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* [Summary] h or script to kill old ftp processes
@ 2001-10-06 20:46 Oyanarte Portilho
  0 siblings, 0 replies; only message in thread
From: Oyanarte Portilho @ 2001-10-06 20:46 UTC (permalink / raw)
  To: tru64-unix-managers

Hi Gurus,

Thanks to Jim Fitzmaurice, Udo de Boer and Michael R. Mehall.
Jim sent me a script, which I have modified slightly in order
to function as desired. Its final form is the following:

...............

#!/bin/ksh
#
for PROID in `ps aux | grep ftp | 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
#

..............

A crontab entry runs it three times a day and it is working fine.
Of course it can be modified to kill periodically any processes. Just
change "ftp" to anything else; also the age limit can be modified
by editing the "8" in LIMIT. However test it before running;
comment the kill line and add an echo ${PROID} just to be sure.

Thanks again Jim.

	Oyanarte Portilho
	Institute of Physics
	University of Brasilia, Brazil

========================
Original posting:

Our ftp server has been very busy after it is mirrowing some very solicited
software in the net. A bunch of anonymous ftp processes are not concluded
due to high traffic and stay filling many lines if we give

ps axu|grep ftp

We would like to kill such processes through a script in crontab, when older
than a certain number of hours. We know how to print the time they have
started, with, for instance,

ps aux | grep ftp | grep -v grep | awk '{print $10}'

but do not know how to achieve what we wish, i. e., compare it with the
current time and kill the process if it older then, say, 8 hours.
Any hints ?

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-10-06 20:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-06 20:46 [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