Linux Classes
Linux Classes
Share This With a Friend
LINUX CLASSES - LINUX BASICS

How Do I Stop a Running Program?

Stop That Task!

Although it's unfortunate, some tasks are unruly and must be killed. If you accidentally entered the (fictitious) command

seek_and_destroy &

you'd have a background task doing potentially nasty things. Pressing the ctrl-C key would have no effect, since it can terminate only a foreground task. Before this rogue eats your system alive, issue the ps -f command to find out the process ID (PID) of the seek_and_destroy task:

ps -f
UID PID PPID STIME TTY TIME COMD
hermie 24 1 00:35:28 tty1 0:01 bash
hermie 1704 24 00:36:39 tty1 0:00 seek_and_destroy

Note that the offender has a PID of 1704 and then quickly issue the command

kill 1704

to terminate the background task.

You can terminate any active task with the kill command, which sends a "terminate gracefully" signal to the running task that allows it to do any necessary cleanup, close files, and so on before giving up the ghost. Occasionally, though , a task will not respond to the kill command, either because a program has become disabled or is coded specifically to ignore it. Time for the heavy artillery. Adding the -9 flag to the kill command, as i n

kill -9 1704

basically sends the "die you gravy-sucking pig" signal to the running task and forces it to shut down immediately without any chance to do cleanup. Use this flag only as a last resort, since it could cause work in progress (by the soon- to-be-killed task) to be lost.

For more information on the kill command, see the kill manual.

Previous Lesson: Processes
Next Lesson: Environment Variables

[ RETURN TO INDEX ]



Comments - most recent first
(Please feel free to answer questions posted by others!)

kk (05 Feb 2013, 07:11)
there are two simple commands one is to view the background running jobs the is #bg

and the second one is #fg to get the improperly closed job to foreground and then close it.

NOTE: never use ctrl+z key because the job will not be terminated but it goes and runes in background.
Angelo (05 Dec 2011, 07:51)
To use this linux you don't need a computer, usually a car is enough. Since when there is more than ONE Internet? GEEEEEEEEEEEEEEZZZZZZZZZZZZZZ
husong (04 Dec 2011, 22:15)
Do I need to make purchase a computer for using this Linux? Will I go to internets?
Linux Master (09 Nov 2011, 19:45)
Yeah you are right, I think they are stupids.
Angelo (07 Oct 2011, 21:23)
It seems that people commenting here are either stupid or spammers
renuka (29 Aug 2011, 01:18)
hi
how to start STAF(software testing automation framework) automatically when machine is started in Linux?
please give me explanation?
reply me soon...:)
elvis oduong (23 Feb 2011, 08:08)
Linux is not commonly used here and should i go for it,i would be operating in my own world. what plans do u have to popularize it?
dave (08 Aug 2010, 11:46)
I tend to use:
ps -A | grep (offending process) to locate what I know is the cause. For example if firefox is hanging I do:

ps -A | grep firefox.

That points me right to the offending process.

I welcome your comments. However... I am puzzled by many people who say "Please send me the Linux tutorial." This website *is* your Linux Tutorial! Read everything here, learn all you can, ask questions if you like. But don't ask me to send what you already have. :-)

NO SPAM! If you post garbage, it will be deleted, and you will be banned.
*Name:
Email:
Notify me about new comments on this page
Hide my email
*Text:




Copyright © by - Privacy Policy
All rights reserved - Redistribution is allowed only with permission.

Popular Linux Topics

Linux Intro
Linux Files
Linux Commands
Change Password
Copy Files
Linux Shell Basics

Linux Tutorial

Who is Doctor Bob?
What is Linux?
History of Unix
Operating Systems
What's Next?

Linux Basics

Living in a Shell
Root and Other Users
Virtual Consoles
Logoff and Shutdown
Choosing a Shell
The Command Prompt
Wildcards
Command History
Aliases
Redirection
Pipelines
Processes
Stopping a Program
Environment Variables
Help!

Linux Files

The Linux File System
Linux File Names
Linux Directories
Directory Terminology
Navigating the File System
Listing Linux Files
Displaying Linux Files
Copying and Renaming Files
Creating Files and Directories
Deleting Files and Directories
Linux Files - Wildcards
The Nine Deadly Keystrokes
Linux File Permissions
Changing File Permissions

Linux Commands

Important Linux Commands
Changing Your Password
Switching Users
Who is Logged In?
Date and Time
The Echo Command
Spell Checking
Printing Linux Files
Joining Files
Searching for Files
Comparing Files
Task Scheduling
Linking Files

Linux Editors

The Vi Editor
The Emacs Editor
The Pico Editor

Linux Data Manipulation

Slicing & Dicing
Heads or Tails?
Sorting Data
Eliminating Duplicates
Selecting Columns
Selecting Records
Search & Replace
Crunching Data
Finding Files
Pipe Fitting

Linux Shell Programming

Linux Shell Scripts
Executing a Script
Shell Script Variables
Shell Script Logic
Shell Script Looping
Shell Script Debugging

Perl Programming

Perl Basics
Perl Variables
Perl Arguments
Perl Logic
Perl Looping
Perl and Files
Perl Pattern Matching

Linux and Email

Sending Email
Reading Email
Other Mail Commands
Using Pine for Email
The Pine Inbox
Pine Email Basics
Pine Email Folders
Pine for Power Users

Compression and Encoding

Linux File Compression
Archiving With Tar
Compression With Gzip
Compress and Zcat
Zmore and Zless
Zip and Unzip
Encoding and Decoding
Encryption

Linux Does DOS

Accesing DOS Files
Accesing DOS Partitions
Running DOS Programs

Managing Linux

Updating Your Linux System
Installing Packages with RPM
Uninstalling Packages w/ RPM
Upgrading Packages with RPM
Querying Packages with RPM

AltStyle によって変換されたページ (->オリジナル) /