[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: How can I get a script to find out what a PID is?



Quickie:

#!/bin/sh
# Need to find PID of x11amp and kill it dead.
#
x11ampPID=`ps -ax | grep x11amp | egrep -v "grep" | awk '{print $1}'`
# Uncomment following line for debugging purposes.
# echo "Killing ${nestPID}"
kill -9 ${x11ampPID}
#
# End script


On Thu, 31 Dec 1998, George Lenzer wrote:

> I would like to be able to kill a process with cron.  Since Process IDs are
> always different, is there a way to kill a process by the application name?

Don't know of a way.

> Or, is there a way to get the process ID and pass it to cron?

See above quickie.

> Alternatively, is there a way to start an application with the same PID
> every time?  In my case, the application is 'x11amp'.  I need to schedule it

Nope, not to my knowledge.

> to quit at a predetermined time.

Place the above script (call it killx11amp and make it executable)
Add the following line to cron by "crontab -e"
30 22 * * * /location/of/killx11amp >/dev/null 2>&1

to kill it at 10:30pm every day.

> 
> Thanks
> --------------------------------------------
>  George H. Lenzer
>  Technology Specialist
>  Cleveland Heights-University Heights
>  P u b l i c  L i b r a r y
>  2345 Lee Rd. Cleveland Heights, Ohio 44118
>  Voice - (216)932-3600 x274
>  E-mail: glenzer chuhpl lib oh us
> --------------------------------------------
> 
> 
Rick
--
Rick L. Mantooth	rickdman cyberramp net
http://www.cyberramp.net/~rickdman
I Support Co-Ed Naked Shell Scripting



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]