LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-13-2010, 04:59 PM   #1
wertum
Member
 
Registered: Jul 2010
Location: usa
Distribution: ubuntu
Posts: 39

Rep: Reputation: 16
How i can kill process of my scriupt?


My script in /usr/bin displays the time on the console tty1 :
Quote:
if [ $(echo &>/dev/null > /dev/tty8; echo $?) -eq 0 ]
then
while [ 1 -lt 2 ]
do
clear > /dev/tty1
date +%H:%M:%S > /dev/tty1
sleep 1
done
else
echo "sudo /etc/init.d/timeconsoled start|stop"
exit 2
fi
I'm started this script : /usr/bin/showtime
How i can kill process of this script.
 
Old 08-13-2010, 05:05 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by wertum View Post
My script in /usr/bin displays the time on the console tty1 : I'm started this script : /usr/bin/showtime
How i can kill process of this script.
Isn't $$ the variable containing the PID ?
 
Old 08-13-2010, 08:56 PM   #3
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Code:
kill $(pidof -x showtime)
kill $(ps -A | grep -w showtime | grep -o '[[:digit:]]\+')  # this can be simplified, man ps
or after running the script:
Code:
/usr/bin/showtime
PID=$!
< later >
kill "$PID"
use 'kill -s 9' instead if you like, run 'man kill' or 'help kill' for more info

Last edited by konsolebox; 08-13-2010 at 08:57 PM.
 
  


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
bash `kill`: process 'B' silently dies; but process 'A' = `kill` spews back debris! GrapefruiTgirl Programming 9 06-23-2009 09:42 AM
why we cannot kill process id 1 with command "kill -9 1" satyaredhat Linux - Newbie 7 03-11-2009 12:48 PM
How to get the PID of the process giving kill signal to a process? hariprd Programming 2 11-27-2008 03:10 AM
Shell Script : Kill a running process when another process starts ashmew2 Linux - General 3 08-20-2008 03:47 AM
cannot kill process (kill -9 does not work) mazer13a Linux - General 1 05-27-2005 02:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:12 AM.

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
Open Source Consulting | Domain Registration