Subj : Remove Oldest Process Every Minute. How To? To : comp.os.linux From : Juul Date : Sat Aug 21 2004 11:52 pm I've build a picturegrabber in PHP that starts every minute from within a shellscript that runs as a cronjob. The PHP-script needs about 5 minutes to complete and sometimes it will hang. That's why I wrote a shellscript for it. Every minute a new session of the PHP-script starts. There can be more than 1 process of the PHP-script active but not more than 6. So the old instances can complete when a new instance of the PHP-script starts. When the 6th process starts then all processes of the PHP-script would be killed by the shellscript. This is my problem... By killing all the processes of the PHP-script it kills also the just started processes and I actually want to kill only the oldest process when the 6th process starts. How can I do this? This is the shellscript I use: ================== #!/bin/sh PS=/bin/ps GREP=/bin/grep WC=/usr/bin/wc PHP=/usr/bin/php AWK=/usr/bin/awk PATH=/local/www/data/cgi-bin COUNT=`$PS -ef | $GREP checkpictures | $GREP -v grep | $WC -l` if [ $COUNT -lt 6 ]; then cd $PATH $PHP ./checkpictures.php > /local/www/data/logs/checkpictures.log 2>&1 else kill -9 `$PS -ef | $GREP checkpictures | $AWK '{ print $2 }'` fi .