LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-30-2008, 06:17 AM   #1
arun_nishad
LQ Newbie
 
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
Killing a background process


I have a shell script:

#!/bin/sh
./hello.sh >> /tmp/x &
tail -f /tmp/x
exit 0

when i do Ctrl-c
tail -f /tmp/x killed
hello.sh does not kill.
How to kill this background process using Ctrl-c ?
 
Old 07-30-2008, 06:25 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Ctrl-C kills the current foreground process. If you want to kill a backgrounded process, either
1. don't background it
Or
2. get the pid and kill that eg

Code:
./hello.sh >> /tmp/x &
bg_pid=$!
kill $bg_pid
See http://www.tldp.org/LDP/abs/html/refcards.html#AEN20710
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find the process ID of process executing in the background akeneche Linux - Newbie 1 01-03-2008 11:08 AM
Killing a process by its name rabeea Linux - Networking 3 03-17-2005 06:30 AM
how to run any binary in background - background process tej Linux - Newbie 1 08-16-2004 01:27 AM
killing background jobs? sk8guitar Linux - General 3 08-09-2003 06:22 AM
Really Killing a Process! lazlow69 Linux - Newbie 14 05-10-2003 11:31 PM


All times are GMT -5. The time now is 12:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration