LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How i can kill process of my scriupt? (https://www.linuxquestions.org/questions/programming-9/how-i-can-kill-process-of-my-scriupt-826090/)

wertum 08-13-2010 04:59 PM

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.

Sergei Steshenko 08-13-2010 05:05 PM

Quote:

Originally Posted by wertum (Post 4065605)
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 ?

konsolebox 08-13-2010 08:56 PM

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


All times are GMT -5. The time now is 07:32 AM.