The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Kill a process without using kill command sudhamacs Linux 6 10-27-2008 12:36 PM
Kill a process without using kill command sudhamacs Shell Programming and Scripting 0 10-01-2008 06:19 PM
Diff b/n kill and kill -9 ammu UNIX for Advanced & Expert Users 2 07-18-2007 06:29 PM
not able to kill find with kill -9 Amardeep UNIX for Dummies Questions & Answers 5 01-04-2007 05:49 PM
When kill doesnt work, how to kill a process ? VijayHegde UNIX for Advanced & Expert Users 3 05-12-2006 05:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-30-2009
mauler123 mauler123 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 9
kill itself

Hey I need to write a script that can kill itself. I have to use the command kill within it.

So I have gotten my head around to that I need to use ps to get the PID but I have no idea how to store that PID in a variable to be able to then kill the script.

So is there a way to grab the PID within the script so that I can kill it?
  #2 (permalink)  
Old 03-30-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,184
Surely "exit" is easier.
The PID of the current shell is
$$
e.g.
PID=$$
echo "${PID}"
Be careful. It is rarely necessary to kill processes which are under control.

Last edited by methyl; 03-30-2009 at 08:09 PM.. Reason: Clarify
  #3 (permalink)  
Old 03-30-2009
mauler123 mauler123 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 9
Except I have to use the kill command. One of those pesky requirements.

EDIT: Sorry I didn't see your explanation at first. Thanks a bunch that was giving me a somewhat hard time. I'm fairly new to unix in general and really do not spend that much time with it.

Last edited by mauler123; 03-31-2009 at 12:22 AM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0