fortypoundhead.com

KILL

Posted On 2007-05-01 by FortyPoundHead
Keywords: Command Reference
Tags: Linux Commandline Linux
Views: 1458


Stop a process from running, either via a signal or forced termination.

SYNTAX
kill [-s sigspec] [-n signum] [-sigspec] jobspec or pid
kill -l [exit_status]

key
-l : List the signal names
-s : Send a specific signal
-n : Send a specific signal numberSend a signal specified by sigspec or signum to the process named by job specification jobspec or process ID pid.

sigspec is either a signal name such as SIGINT (with or without the SIG prefix) or a signal number; signum is a signal number.

If sigspec and signum are not present, SIGTERM is used (Terminate).

If any arguments are supplied when `-l'' is given, the names of the signals corresponding to the arguments are listed, and the return status is zero. exit_status is a number specifying a signal number or the exit status of a process terminated by a signal.

The return status is zero if at least one signal was successfully sent, or non-zero if an error occurs or an invalid option is encountered.


List the running process
$ ps
PID TTY TIME CMD
1293 pts/5 00:00:00 MyProgram

Then Kill it
$ kill 1293
[2]+ Terminated MyProgram

To run a command and then kill it after 5 seconds:

my_command & sleep 5
kill -0 $! && kill $!


About the Author

FortyPoundHead has posted a total of 1974 articles.

 


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.80.247.254

Before you can post, you need to prove you are human. If you log in, this test goes away.



Recent Forum Posts

List of Shady Characters
dwirch posted on April 25, 2017 at about 16:39 in Webmaster Stuff

Job Spammer: Bilal Uddin
dwirch posted on April 25, 2017 at about 11:00 in Spammers

Bug Fix: Contact Form Error
dwirch posted on April 21, 2017 at about 11:38 in Site News

Bug Fix: Ophion Time Tracker
dwirch posted on April 9, 2017 at about 11:30 in Site News

Job Spammer: Yogesh Kapadne
dwirch posted on March 31, 2017 at about 8:04 in Spammers

Job Spammer: Sathya Narayana
dwirch posted on March 15, 2017 at about 7:18 in Spammers