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 08-23-2010, 01:54 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
Process ID changing ubruptly while killing mysqld


Hi All,

I tried to stop mysqld deamon. It failed
Code:
[zabbix@CDCTGIMCLSA ~]$ sudo /etc/init.d/mysqld stop
Stopping MySQL:                                            [FAILED]
Then I tried to kill the process, but Process Id is getting changed ubruptly.

Code:
[zabbix@CDCTGIMCLSA ~]$ ps -e | grep mysql
 5954 pts/1    00:00:00 mysqld
27338 pts/1    00:00:01 mysqld_safe
[zabbix@CDCTGIMCLSA ~]$ sudo kill -9 5954
kill 5954: No such process
[zabbix@CDCTGIMCLSA ~]$ ps -e | grep mysql
 6155 pts/1    00:00:00 mysqld
27338 pts/1    00:00:02 mysqld_safe
[zabbix@CDCTGIMCLSA ~]$ sudo kill -9 6155
kill 6155: No such process
[zabbix@CDCTGIMCLSA ~]$ ps -e | grep mysql
 6315 pts/1    00:00:00 mysqld
27338 pts/1    00:00:02 mysqld_safe
But following works !!
Code:
 sudo kill -9 `pgrep mysqld`
Any reason for this ubrupt changing pid ?

Last edited by vinaytp; 08-23-2010 at 01:56 AM.
 
Old 08-23-2010, 02:08 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Check if mysqld_safe is the parent

Code:
ps -ef|grep mysql
I don't have Linux system in front of me to check right now.
 
Old 08-23-2010, 02:19 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
Thanks for your reply chrism01.

Here mysqld seems to be the parent as mysqld PID 17705 < mysqld_safe PID 23163

Code:
[308718@CDCTGIMCLSB ~]$ sudo /sbin/service mysqld stop
Stopping MySQL:                                            [FAILED]
[308718@CDCTGIMCLSB ~]$ ps -e | grep mysql
17705 ?        00:00:00 mysqld
23163 ?        00:00:06 mysqld_safe

Last edited by vinaytp; 08-23-2010 at 02:45 AM.
 
Old 08-23-2010, 03:20 AM   #4
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
Quote:
Check if mysqld_safe is the parent
chrism01 is right

run pstree | grep mysql and you will find parent and child process

Code:
debian:~# pstree | grep mysql
     |-mysqld_safe-+-logger
     |             `-mysqld---27*[{mysqld}]
if single instant running on server you can user pkill command

Code:
# ps -e | grep mysql
  2837 ?        00:00:00 mysqld_safe
  2874 ?        00:00:11 mysqld
# pkill -15 mysqld
# pkill -15 mysqld_safe
# ps -e | grep mysql
HTH
 
Old 08-23-2010, 03:49 AM   #5
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
Thanks sem007,

Here mysqld_safe seems to be the parenet with pstree command

Code:
[zabbix@CDCTGIMCLSA ~]$ sudo pstree | grep mysq
     |-mysqld_safe---mysqld---9*[{mysqld}]
But is it Okay to kill a process with pkill or Kill, when the deamon can't be stopped with

Code:
/etc/init.d/mysqld stop
 
Old 08-23-2010, 03:52 AM   #6
Kenny_Strawn
Senior Member
 
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Blog Entries: 62

Rep: Reputation: 56
Here's a thought:

Code:
killall /etc/init.d/mysqld
 
Old 08-23-2010, 03:59 AM   #7
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
just run pkill command to kill mysqld

Code:
[root@localhost ~]# ps aux | grep mysql
root      1711  0.0  0.1   4492  1104 pts/3    S    21:46   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --user=mysql
mysql     1767  0.1  1.6 137188 17048 pts/3    Sl   21:46   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
root      1798  0.0  0.0   3920   660 pts/3    R+   21:48   0:00 grep mysql


[root@localhost ~]# pkill -9 mysqld


[root@localhost ~]# ps aux | grep mysql
root      1802  0.0  0.0   3920   656 pts/3    S+   21:48   0:00 grep mysql

[root@localhost ~]#
@ Kenny_Strawn

Quote:

Code:

killall /etc/init.d/mysqld
it gives me error

Code:
[root@localhost ~]# ps -e | grep mysql
 1849 pts/3    00:00:00 mysqld_safe
 1909 pts/3    00:00:00 mysqld

[root@localhost ~]# killall /etc/init.d/mysqld
/etc/init.d/mysqld: no process killed

[root@localhost ~]#

[EDIT]

when i run below command it works

killall mysqld

Last edited by sem007; 08-23-2010 at 04:02 AM. Reason: post result
 
Old 08-23-2010, 04:04 AM   #8
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
@sem007,

Yeah I got it how this pkill works. But my question is, does killing a process with pkill or kill cause abrupt deamon stop ?

Is it the step taken when the deamon fails to stop ?

@ Kenny_Strawn

This gives error..
Code:
[root@localhost ~]# killall /etc/init.d/mysqld
/etc/init.d/mysqld: no process killed
[root@localhost ~]#
 
Old 08-23-2010, 04:10 AM   #9
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
Quote:
Yeah I got it how this pkill works. But my question is, does killing a process with pkill or kill cause abrupt deamon stop ?

Is it the step taken when the deamon fails to stop ?
when you stop service it will use kill command to terminate process.

some lines from /etc/init.d/mysqld script
Code:
stop(){
        MYSQLPID=`cat "$mypidfile"  2>/dev/null `
        if [ -n "$MYSQLPID" ]; then
            /bin/kill "$MYSQLPID" >/dev/null 2>&1
I advise use signal 15 (TERM) when you kill process.

HTH
 
Old 08-23-2010, 04:30 AM   #10
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
You should use ps -ef (full format) instead of ps -e. I'm pretty sure you will recognize that: mysqld_safe is parent process of mysqld:
Code:
# ps -ef | grep mysqld
root      2657     1  0 Jun13 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --user=mysql
mysql     2707  2657  0 Jun13 ?        03:19:36 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
 
Old 08-23-2010, 04:49 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Exactly, the relative values of the pids is irrelevant, the system pids wrap around after 4 digits...
 
Old 08-23-2010, 05:22 AM   #12
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
@quanta, @chrism01, @sem007
Thank you for your advices.
 
  


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
Killing More than one process ruud Programming 11 04-27-2010 07:30 AM
Process still running even after killing coolguy_iiit Linux - Newbie 1 07-30-2006 09:30 AM
Killing a process by its name rabeea Linux - Networking 3 03-17-2005 06:30 AM
Changing ownership of mysqld process macdav76 Linux - Newbie 0 12-08-2003 06:24 PM
Really Killing a Process! lazlow69 Linux - Newbie 14 05-10-2003 11:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:36 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration