There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
UNIX/Linux
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox format freezes freezing hard drive hardware hijackthis internet internet explorer itunes laptop malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound spyware trojan usb virus vista vista 32-bit windows windowsxp windows xp winxp wireless
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > UNIX/Linux >
shell script [plz help]


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
mccrack's Avatar
Junior Member with 2 posts.
 
Join Date: Dec 2004
Experience: Beginner
21-Dec-2004, 12:59 PM #1
shell script [plz help]
Morning Ladies & Gents .

I need to cron a script that kills a process every evening . ( the cron's not the prob, it's the script ) . Getting the PID too kill is the problem . This is what i'm doing .

--------------------------------------------------------------
#/bin/bash
pid= ps -ef | grep process | grep -v grep | awk '{print $2}'
# the above gives me the PID
kill -9 $pid
--------------------------------------------------------------

the kill -9 however cant see the result of $pid

any ideas will be greatly appreciated.



Regards

Ronald
Squashman's Avatar
Distinguished Member with 12,741 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Dec-2004, 01:35 PM #2
Is there more than one PID associated with that process?
Do you have rights to kill the process?
What user is trying to kill the process?
What happens when you do it from the command line?
Can you just keep piping the output to the kill command?

Last edited by LwdSquashman : 21-Dec-2004 01:43 PM.
Squashman's Avatar
Distinguished Member with 12,741 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Dec-2004, 01:46 PM #3
Oh crap. I know what the problem is. You need that in Single back ticks.

pid=`ps -ef | grep process | grep -v grep | awk '{print $2}'`
mccrack's Avatar
Junior Member with 2 posts.
 
Join Date: Dec 2004
Experience: Beginner
21-Dec-2004, 01:53 PM #4
You are an absoloute star!!!!! Thanx , that did the trick !!!!
Hmmm, back ticks .... never would have thought.

regards

ronald
Squashman's Avatar
Distinguished Member with 12,741 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Dec-2004, 02:05 PM #5
Quote:
Originally Posted by mccrack
You are an absoloute star!!!!! Thanx , that did the trick !!!!
Hmmm, back ticks .... never would have thought.

regards

ronald
That is how you have to do it. Otherwise PID actually equals ps -ef | grep process | grep -v grep | awk '{print $2}'. Instead of the actual PID number.

Putting everything in back ticks tells your shell to execute everything within the back ticks.

I feel stupid for not seeing it right away.
__________________
I hate asking the same question twice!
How to ask questions the smart way!
Microsoft MVP - Windows Shell/User
Whiteskin's Avatar
Distinguished Member with 2,051 posts.
 
Join Date: Nov 2002
Location: Alberta, Canada
Experience: Windows: Decent. Unix/Linux: Advanced +1
21-Dec-2004, 03:02 PM #6
I suppose that's something I ought to get onto; Learning awk and sed.
Squashman's Avatar
Distinguished Member with 12,741 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Dec-2004, 04:21 PM #7
Quote:
Originally Posted by Whiteskin
I suppose that's something I ought to get onto; Learning awk and sed.
I have been starting to use them both the last couple of months. The more I use them the more I like them. There is so much I don't know about either of them. They are both very powerful programs.
tsunam's Avatar
Senior Member with 1,246 posts.
 
Join Date: Sep 2003
Experience: Linux~su
21-Dec-2004, 04:39 PM #8
I love awk, great useful app. I should learn sed but I'd have to learn the nromal imput method of it and ughuu~ it looks ugly.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 05:30 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.