From: apogeusistemas on
Hi:

Can you tell me how kill process with more than one day (solaris)?

Thanks.
From: newhorizon on
you can process output of
"ps "
to find the processes ids that are older than one day (you can use
"awk" for that )

then you can kill them :)

but why do you wanna kill the processes older than one day you may
kill system processes as well ?

From: apogeusistemas on
On Jun 20, 10:40 am, newhorizon <mehmete...(a)gmail.com> wrote:
> you can process output of
> "ps "
> to find the processes ids that are older than one day (you can use
> "awk" for that )
>
> then you can kill them :)
>
> but why do you wanna kill the processes older than one day you may
> kill system processes as well ?


Thank you, I create this script below :

ps -ef | grep -v grep | grep deport > /tmp/killpr.txt
while read a b c d e f g h i j k l m n o p q r s
do
process=`echo $e | awk '{print length}'`
if [ $process -eq 3 ]
then
echo "$b $e"
kill -9 $b
fi
done < /tmp/killpr.txt
From: Bill Marcum on
On 2008-06-20, apogeusistemas(a)gmail.com <apogeusistemas(a)gmail.com> wrote:
>
>
> On Jun 20, 10:40�am, newhorizon <mehmete...(a)gmail.com> wrote:
>> you can process output of
>> "ps "
>> to find the processes ids that are older than one day (you can use
>> "awk" for that )
>>
>> then you can kill them :)
>>
>> but why do you wanna kill the processes older than one day you may
>> kill system processes as well ?
>
>
> Thank you, I create this script below :
>
> ps -ef | grep -v grep | grep deport > /tmp/killpr.txt
> while read a b c d e f g h i j k l m n o p q r s
> do
> process=`echo $e | awk '{print length}'`
> if [ $process -eq 3 ]
> then
> echo "$b $e"
> kill -9 $b
> fi
> done < /tmp/killpr.txt

If you aren't using all those variables, you could write
while read a b c d e f
$f will contain the sixth field and all subsequent fields on each line.
From: Maxwell Lol on
apogeusistemas(a)gmail.com writes:

> Thank you, I create this script below :
>
> ps -ef | grep -v grep | grep deport > /tmp/killpr.txt
> while read a b c d e f g h i j k l m n o p q r s
> do
> process=`echo $e | awk '{print length}'`
> if [ $process -eq 3 ]
> then
> echo "$b $e"
> kill -9 $b
> fi
> done < /tmp/killpr.txt

It's usually better to kill with -1 or -15 instead of -9
-1 is the hangup/HUP signal and this usually occurs if a connection is lost.

-15 is the normal command, and tells processes to close all files
cleanly, kill subprocesses, etc.


If you kill with -9, then the process cannot exit cleanly. It may
leave files partially written do, sub-processes still running.


I usually use a script to kill a process that first tries -1, then
waits, then tries -15, and waits, and if it's still running after X
minutes, a kill -9.