LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 04-26-2009, 02:17 AM   #1
il-uvatar
Member
 
Registered: Mar 2009
Posts: 30

Rep: Reputation: 15
Question How to KILL a process or program ?


Can someone help me or tell me what I am doing wrong ?

I'm trying to update a database using mysql. I realise that I have to kill a process "mythbackend" in order to do so.

I have tried listing the running processes using "ps -A". I get the following:
[root@localhost root]# ps -A
PID TTY TIME CMD
1 ? 00:00:01 init
2 ? 00:00:00 ksoftirqd/0
3 ? 00:00:00 events/0
4 ? 00:00:00 khelper
5 ? 00:00:00 kacpid
44 ? 00:00:00 kblockd/0
54 ? 00:00:00 vesafb
57 ? 00:00:00 pdflush
58 ? 00:00:00 pdflush
60 ? 00:00:00 aio/0
59 ? 00:00:00 kswapd0
163 ? 00:00:00 kseriod
172 ? 00:00:00 kjournald
387 ? 00:00:00 devfsd
518 ? 00:00:00 khubd
921 ? 00:00:00 kjournald
1810 ? 00:00:00 ifplugd
1895 ? 00:00:00 mysqld_safe
1979 ? 00:00:00 netplugd
1999 ? 00:00:00 mysqld
2029 ? 00:00:00 portmap
2053 ? 00:00:00 syslogd
2061 ? 00:00:00 klogd
2545 ? 00:00:00 xfs
2619 ? 00:00:00 acpid
2661 ? 00:00:00 sshd
2704 ? 00:00:00 xinetd
2995 ? 00:00:00 crond
3021 ? 00:00:00 smbd
3031 ? 00:00:00 nmbd
3181 ? 00:00:00 httpd-perl
3188 ? 00:00:00 advxsplitlogfil
3189 ? 00:00:00 httpd-perl
3190 ? 00:00:00 httpd-perl
3191 ? 00:00:00 httpd-perl
3192 ? 00:00:00 httpd-perl
3326 ? 00:00:00 lircd
3329 ? 00:00:00 lircd2
3359 tty1 00:00:00 mingetty
3366 tty2 00:00:00 mingetty
3367 tty3 00:00:00 mingetty
3368 tty4 00:00:00 mingetty
3369 tty5 00:00:00 mingetty
3370 tty6 00:00:00 mingetty
3530 ? 00:00:00 mythfrontinit
4563 ? 00:00:00 sshd
4565 ? 00:00:00 sftp-server
4579 ? 00:00:00 sshd
4581 pts42 00:00:00 bash
4909 ? 00:00:00 mythbackinit
5117 ? 00:00:00 mythbackend
5118 ? 00:00:00 startx
5129 ? 00:00:00 xinit
5130 ? 00:00:01 X
5131 ? 00:00:01 mythfrontend
5153 ? 00:00:00 kdvb-fe-0:0
5160 ? 00:00:00 sh
5163 ? 00:00:00 irexec
5164 ? 00:00:00 unclutter
5166 ? 00:00:00 sWM
5187 pts42 00:00:00 ps

I then issue the command "kill 5117".

When I list the processes again, it is still there (but with a different PID) !

Then I tried killing both mythbackinit and mythbackend (using their PIDs) and the same thing happened. They keep restaring like the Hydra !!

Can anyone please help?
 
Old 04-26-2009, 02:40 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
kill -15 process_id

EDIT:

If Myth has a startup/shutdown script, you would be better off running that.

-15 should be the default kill signal.

man kill for information on the different signals.

kill -9 should only be used as a last resort.

Last edited by Disillusionist; 04-26-2009 at 02:47 AM.
 
Old 04-26-2009, 02:47 AM   #3
vlademir
Member
 
Registered: Jan 2009
Location: The Netherlands
Distribution: Centos,Ubuntu,Mandriva,Suse11.1
Posts: 86

Rep: Reputation: 17
Please see this link is more detailled about how to kill a process on Linux/unix Bsd.

http://www.cyberciti.biz/faq/kill-process-in-linux-or-terminate-a-process-in-unix-or-linux-systems/
 
Old 04-26-2009, 02:55 AM   #4
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 61
Mythbackend normally has an init script, so that it runs on boot.

On Debian / Ubuntu you just need to run:
Code:
sudo /etc/init.d/mythbackend stop
--Ian
 
Old 04-26-2009, 03:31 AM   #5
il-uvatar
Member
 
Registered: Mar 2009
Posts: 30

Original Poster
Rep: Reputation: 15
I have a D1 HMC which runds Mandrake 10.0.

My binary appears to be stored in /usr/local/bin.

I ran /usr/local/bin/mythbackend stop and got the reply:

[root@localhost bin]# /usr/local/bin/mythbackend stop
Invalid argument: stop
Valid options are:
-l or --logfile filename Writes STDERR and STDOUT messages to filename
-p or --pidfile filename Write PID of mythbackend to filename
-d or --daemon Runs mythbackend as a daemon
-n or --noautoshutdonw Blocks the auto shutdown routine, so that the
backend will stay alive
-v or --verbose debug-level Prints more information
Accepts any combination (separated by comma)
of all,none,quiet,record,playback,
channel,osd,file,schedule,network
--printexpire List of auto-expire programs
--printsched Upcoming scheduled programs
--version Version information

Any more clues would be helpful ?

P.S. I also tried the kill -15 process_id and it had no effect !

Last edited by il-uvatar; 04-26-2009 at 06:40 AM. Reason: Punctuation
 
Old 04-26-2009, 06:51 AM   #6
il-uvatar
Member
 
Registered: Mar 2009
Posts: 30

Original Poster
Rep: Reputation: 15
OK. I think I understand a little more.....

mythbackend "re-appears" because some other process is "respawning" the dead process. I used “ps axf” and got the following (after trying to "kill" mythbackend yet again):

[root@localhost bin]# ps axf
PID TTY STAT TIME COMMAND
1 ? S 0:01 init [4]
2 ? SWN 0:00 [ksoftirqd/0]
3 ? SW< 0:08 [events/0]
4 ? SW< 0:00 \_ [khelper]
5 ? SW< 0:00 \_ [kacpid]
44 ? SW< 0:00 \_ [kblockd/0]
57 ? SW 0:00 \_ [pdflush]
58 ? SW 0:00 \_ [pdflush]
60 ? SW< 0:00 \_ [aio/0]
54 ? SW< 0:19 [vesafb]
59 ? SW 0:00 [kswapd0]
163 ? SW 0:00 [kseriod]
172 ? SW 0:00 [kjournald]
387 ? S 0:01 devfsd /dev
518 ? SW 0:00 [khubd]
921 ? SW 0:00 [kjournald]
1810 ? S 0:00 /sbin/ifplugd -w -b -i eth0
1895 ? S 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.pid
1999 ? S 0:00 \_ /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/lo
1979 ? S 0:00 /sbin/netplugd -p /var/run/netplugd.pid
2029 ? S 0:00 portmap
2053 ? S 0:00 syslogd -m 0
2061 ? S 0:00 klogd -2
2545 ? S 0:10 xfs -port -1 -daemon -droppriv -user xfs
2619 ? S 0:00 /usr/sbin/acpid
2661 ? S 0:01 /usr/sbin/sshd
4563 ? S 0:00 \_ sshd: root@notty
4565 ? S 0:00 | \_ /usr/lib/ssh/sftp-server
4579 ? S 0:00 \_ sshd: root@pts/42
4581 pts42 R 0:00 \_ -bash
26042 pts42 R 0:00 \_ ps axf
2704 ? S 0:00 xinetd -stayalive -reuse -pidfile /var/run/xinetd.pid
2995 ? S 0:00 crond
3021 ? S 0:00 smbd -D
3031 ? S 0:00 nmbd -D
3181 ? S 0:00 httpd-perl -f /etc/httpd/conf/httpd-perl.conf -DHAVE_PHP4 -DHAVE_HTTPD -DHAVE_PROXY -DHAVE_ACCESS -
3188 ? S 0:00 \_ /usr/bin/perl /usr/sbin/advxsplitlogfile
3189 ? S 0:00 \_ httpd-perl -f /etc/httpd/conf/httpd-perl.conf -DHAVE_PHP4 -DHAVE_HTTPD -DHAVE_PROXY -DHAVE_ACCE
3190 ? S 0:00 \_ httpd-perl -f /etc/httpd/conf/httpd-perl.conf -DHAVE_PHP4 -DHAVE_HTTPD -DHAVE_PROXY -DHAVE_ACCE
3191 ? S 0:00 \_ httpd-perl -f /etc/httpd/conf/httpd-perl.conf -DHAVE_PHP4 -DHAVE_HTTPD -DHAVE_PROXY -DHAVE_ACCE
3192 ? S 0:00 \_ httpd-perl -f /etc/httpd/conf/httpd-perl.conf -DHAVE_PHP4 -DHAVE_HTTPD -DHAVE_PROXY -DHAVE_ACCE
3326 ? S 0:00 /usr/local/sbin/lircd
3329 ? S 0:00 /usr/local/sbin/lircd2
3359 tty1 S 0:00 /sbin/mingetty tty1
3366 tty2 S 0:00 /sbin/mingetty tty2
3367 tty3 S 0:00 /sbin/mingetty tty3
3368 tty4 S 0:00 /sbin/mingetty tty4
3369 tty5 S 0:00 /sbin/mingetty tty5
3370 tty6 S 0:00 /sbin/mingetty tty6
3530 ? S 0:01 /bin/bash /usr/local/bin/mythfrontinit
25995 ? S 0:00 \_ /bin/sh /usr/X11R6/bin/startx -- -allowMouseOpenFail
26007 ? S 0:00 | \_ xinit /root/.xinitrc -- -allowMouseOpenFail -deferglyphs 16
26008 ? S<L 0:01 | \_ /etc/X11/X :0 -allowMouseOpenFail -deferglyphs 16
26028 ? S 0:00 | \_ sh /root/.xinitrc
26036 ? S 0:00 | \_ irexec
26037 ? S 0:00 | \_ unclutter -root -idle 0
26039 ? S 0:00 | \_ sWM
26000 ? R 0:00 \_ mythfrontend
25883 ? S 0:00 /bin/bash /usr/local/bin/mythbackinit
25973 ? S 0:00 \_ /usr/local/bin/mythbackend
25981 ? SW 0:00 [kdvb-fe-0:0]

The trouble is, I do not understand this output !

Last edited by il-uvatar; 04-26-2009 at 06:51 AM. Reason: punctuation
 
Old 04-26-2009, 07:35 AM   #7
metrofox
Member
 
Registered: Jan 2009
Location: Palermo, Italy
Distribution: Slackware
Posts: 236

Rep: Reputation: 37
Use "top":

Code:
top
Search your process and its PID, once found press "k" and it will lock all results, put the process' PID on and after push enter button twice. It seems to be hard or slow as procedure, but it works.
 
Old 04-26-2009, 09:11 AM   #8
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
Try:
Code:
service mythbackend stop
 
Old 04-26-2009, 10:10 AM   #9
mark_alfred
Senior Member
 
Registered: Jul 2003
Location: Toronto, Ontario, Canada
Distribution: Ubuntu Linux
Posts: 1,033

Rep: Reputation: 95
Quote:
Originally Posted by metrofox View Post
Use "top"
htop (in the terminal) is also good. Like top, it lists all the running processes. You can then highlight one, and kill it with the displayed menu options (in the case of htop, it would be pressing F9, then enter.) htop is a nicer display than top, I feel. Just install htop, and then killing processes is quite simple.

Actually, simply typing "killall mythbackend" would also work, I believe.

Last edited by mark_alfred; 04-26-2009 at 10:13 AM.
 
Old 04-27-2009, 02:34 AM   #10
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 342

Rep: Reputation: 38
Try doing a pstree -p

And see what process is the parent. If it is not init, then kill the parent before killing its children, and it should stay dead.

Alternatively, find the daemon that keeps starting these processes and kill that one.
 
Old 04-27-2009, 03:08 AM   #11
il-uvatar
Member
 
Registered: Mar 2009
Posts: 30

Original Poster
Rep: Reputation: 15
OK. I did a "pstree -p" and here's an extract from that:

|-mysqld_safe(1823)---mysqld(1869)
|-mythbackinit(5991)---mythbackend(6242)
|-mythfrontinit(5967)-+-mythfrontend(6203)
| `-startx(6194)---xinit(6207)-+-X(6208)
| `-sh(6227)-+-irexec(6235)
| |-sWM(6238)
| `-unclutter(6236)
|-netplugd(1911)


Next I did:

[root@localhost root]# kill -9 5991
[root@localhost root]# kill -9 6242



Then I did "pstree -p" again and got:


|-mythbackinit(6285)---mythbackend(6431)
|-mythfrontinit(5967)-+-mythfrontend(6412)
| `-startx(6399)---xinit(6410)-+-X(6411)
| `-sh(6442)-+-irexec(6445)
| |-sWM(6448)
| `-unclutter(6446)


I thought that if I killed the parent, the child processes would also die.

What is going on ?
 
Old 04-27-2009, 06:25 AM   #12
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 61
What's going on is that the process is being automatically restarted everytime it is killed. You can see this from the fact that the PID has changed the second time you run pstree.

Have you tried:
Code:
service mythbackend stop
?

Because MythBackend is a service, it is probably being monitored by some other process to ensure that it is always running. Obviously if you are running a MythTV box, you want the backend to restart if it crashes.
 
Old 04-27-2009, 06:48 AM   #13
il-uvatar
Member
 
Registered: Mar 2009
Posts: 30

Original Poster
Rep: Reputation: 15
I get the following:

[root@localhost root]# service mythbackend stop
Cannot find mythbackend service
Usage: service -[Rfshv] SERVICE ARGUMENTS
-f|--full-restart: Do a fullrestart of the service.
-R|--full-restart-all: Do a fullrestart of all services currently running.
-s|--status-all: Print a status of all services.
-d|--debug: Launch with debug.
-h|--help: This help.
-v|--version: Print version.

version 1.14
 
Old 04-27-2009, 01:14 PM   #14
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 342

Rep: Reputation: 38
You didn't tell us what distro you are using, but from the fact that you have the service command, it means it's a Red-Hat, Fedora, or, CentOS, or any other derivative.

Can you please do a

Code:
rpm -qa | grep myth
And paste the output here.

Please note that this will list all the versions of the packages with myth in their name that you have installed on your system. This is a security risk if you have any services publicly accessible on your pc. So please think about this before posting the output.

Thanks.
 
Old 04-27-2009, 07:06 PM   #15
yiye62
LQ Newbie
 
Registered: Aug 2004
Posts: 1

Rep: Reputation: 0
What signal handler do you use in mythbackend process? Every signal handler is default or someone is your own.
 
  


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
Kill a process akhtar.bhat Linux - Software 1 12-28-2008 08:26 AM
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
Cannot kill process - please help! thomas.nichols Linux - General 16 09-05-2001 06:43 AM


All times are GMT -5. The time now is 01:37 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration