AIX script

AIX script

Post by Luis Rosale » Thu, 20 Jun 2002 06:18:38



I need to be able to kill a process at midnight every day.  What I have so
far is this.

I run ps -fu user -o "pid,comm" | grep "sql"
and It returns: 35344 _sqlsrv2
I need a script that would run that command and then based on what it
returns, in this case a PID of 35344, issue a
kill -kill 35344

Can anyone lend a hand here.
Thank You

 
 
 

AIX script

Post by Ben Kame » Thu, 20 Jun 2002 06:37:03


kill -9 $(ps -fu user -o "pid,comm" | grep "sql" | awk '{$1}')

That should work... hollar if it doesn't.

  -Ben


> I need to be able to kill a process at midnight every day.  What I have so
> far is this.

> I run ps -fu user -o "pid,comm" | grep "sql"
> and It returns: 35344 _sqlsrv2
> I need a script that would run that command and then based on what it
> returns, in this case a PID of 35344, issue a
> kill -kill 35344

> Can anyone lend a hand here.
> Thank You

--
Ben Kamen - Fixer of Broken Things
======================================================================


 
 
 

AIX script

Post by Ben Kame » Thu, 20 Jun 2002 07:03:56


Oops, that should be:

kill -9 $(ps -fu user -o "pid,comm" | grep "sql" | awk '{print $1}')


> kill -9 $(ps -fu user -o "pid,comm" | grep "sql" | awk '{$1}')

> That should work... hollar if it doesn't.

>  -Ben


>> I need to be able to kill a process at midnight every day.  What I
>> have so
>> far is this.

>> I run ps -fu user -o "pid,comm" | grep "sql"
>> and It returns: 35344 _sqlsrv2
>> I need a script that would run that command and then based on what it
>> returns, in this case a PID of 35344, issue a
>> kill -kill 35344

>> Can anyone lend a hand here.
>> Thank You

--
Ben Kamen - Fixer of Broken Things
======================================================================

 
 
 

AIX script

Post by Luis Rosale » Thu, 20 Jun 2002 07:01:41


Thanks for the reply.  Tried it, and I get the following.
awk: 0602-550 A statement occurred that is not valid.
 The input line number is 1.
 The source line number is 1.


> kill -9 $(ps -fu user -o "pid,comm" | grep "sql" | awk '{$1}')

> That should work... hollar if it doesn't.

>   -Ben


> > I need to be able to kill a process at midnight every day.  What I have
so
> > far is this.

> > I run ps -fu user -o "pid,comm" | grep "sql"
> > and It returns: 35344 _sqlsrv2
> > I need a script that would run that command and then based on what it
> > returns, in this case a PID of 35344, issue a
> > kill -kill 35344

> > Can anyone lend a hand here.
> > Thank You

> --
> Ben Kamen - Fixer of Broken Things
> ======================================================================


 
 
 

AIX script

Post by Luis Rosale » Thu, 20 Jun 2002 08:51:56


Thank you very much, Ben.  Worked like a charm.


> Oops, that should be:

> kill -9 $(ps -fu user -o "pid,comm" | grep "sql" | awk '{print $1}')


> > kill -9 $(ps -fu user -o "pid,comm" | grep "sql" | awk '{$1}')

> > That should work... hollar if it doesn't.

> >  -Ben


> >> I need to be able to kill a process at midnight every day.  What I
> >> have so
> >> far is this.

> >> I run ps -fu user -o "pid,comm" | grep "sql"
> >> and It returns: 35344 _sqlsrv2
> >> I need a script that would run that command and then based on what it
> >> returns, in this case a PID of 35344, issue a
> >> kill -kill 35344

> >> Can anyone lend a hand here.
> >> Thank You

> --
> Ben Kamen - Fixer of Broken Things
> ======================================================================


 
 
 

AIX script

Post by Stefan Llabr » Fri, 21 Jun 2002 00:57:56



> Thanks for the reply.  Tried it, and I get the following.
> awk: 0602-550 A statement occurred that is not valid.
>  The input line number is 1.
>  The source line number is 1.



> > kill -9 $(ps -fu user -o "pid,comm" | grep "sql" | awk '{$1}')

The "print" is missing in the awk command and you don't need
the grep as awk can "grep" itself.

kill -9 $(ps -fu user -o "pid,comm" | awk '/sql/ {print $1}')

Bye, Stefan...  .      .

 
 
 

AIX script

Post by Ben Kame » Fri, 21 Jun 2002 03:38:50


I replied again fixing the missing "print"...
as for grepping though awk - ya, I was half asleep.. sorry..

:)

  -Ben



>>Thanks for the reply.  Tried it, and I get the following.
>>awk: 0602-550 A statement occurred that is not valid.
>> The input line number is 1.
>> The source line number is 1.



>>>kill -9 $(ps -fu user -o "pid,comm" | grep "sql" | awk '{$1}')

> The "print" is missing in the awk command and you don't need
> the grep as awk can "grep" itself.

> kill -9 $(ps -fu user -o "pid,comm" | awk '/sql/ {print $1}')

> Bye, Stefan...  .      .

--
Ben Kamen - Fixer of Broken Things
======================================================================

 
 
 

1. AIX Script: Does anyone know how to load a tape using aix script

Hi Everyone:
I am trying to write  a script that will loadt a tape from a SCSI
connected tape drive.I have tried tctl -f /dev/rmt* offline/rewoff1 to
eject but none toload it.




Ronald Farris
1002 N. Jerrie #3
Tucson, AZ 85711

Tel: (520) 881-3750
http://community.webtv.net/ronfarris/NOVELLNETWORKINGII

2. DDK for SunOs?

3. AIX-Script on RS6000 SP2

4. Hp DeskJet820Cse will it work?

5. Aix scripts

6. About to take the plunge, and needing help...

7. Question about writing aix scripts

8. ftp- can mget descend?

9. AIX Script to Summarize By First Column By Adding Values in Numerical Columns

10. AIX Script to enable login

11. FTP as/400 to aix script, need help

12. FTP script on AIX 2.2.1 (AIX on RT 6150)

13. AIX 432 - ksh -x option when script calls another script