LinuxQuestions.org
Visit Jeremy's Blog.
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 05-02-2008, 08:39 AM   #1
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Rep: Reputation: 39
Angry Extremely annoying having a paddy weird issue with ps command and . /etc/rc.status


Hi All,
Going absolutely bonkers over this problem aaarrrgghhhh :-)

I've created a start-up script which works great everywhere else but on this server it doesn't, it works but it doesn't evaluate things quite correctly. and the main thing is:-
i run
ps -ef | grep -v grep | blah blah blah

and in the same script im running . /etc/rc.status so i can start and stop my service with the startproc and killproc etc etc.

Now i've just realized and worked out that running:-
ps -ef
. /etc/rc.status

makes ps -ef work as it would normally if i just executed it on the shell, however from the same script if i execute in a different order
. /etc/rc.status
ps -ef

then the ps give totally different output, now the ps -ef isn't run directly after the . /etc/rc.status but you get the idea. Its driving me bonkers, i'm runnig sles 10

Any idea what is going on there
????
Cheers
 
Old 05-02-2008, 11:20 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Quote:
Originally Posted by helptonewbie View Post
the main thing is:- i run ps -ef | grep -v grep | blah blah blah
Prolly using 'ps' where you should use 'pgrep' instead. If that's not it just post your script and dr. Allcome will be here soon.
 
Old 05-02-2008, 11:32 AM   #3
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
Hey There, i'll give you a quick example of what i found is going on...very strange...

script i've quickly made up to show whats happening....
#!/bin/bash
ps -ef | grep "/bin/sh /usr/bin/mysqld_safe"
. /etc/rc.status
echo ""
echo ""
ps -ef | grep "/bin/sh /usr/bin/mysqld_safe"

OUTPUT of that script is:-
root 3645 1 0 14:02 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --user=mysql --pid-file=/var/lib/mysql/mysqld.pid --socket=/var/lib/mysql/mysql.sock --datadir=/var/lib/mysql
root 8207 8205 0 16:29 pts/0 00:00:00 grep /bin/sh /usr/bin/mysqld_safe
root 3645 1 0 14:02 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --u

Thats the output exactly, yes it seems to cut half of it off, so in my script when i grep something i'm grepping to much of the string to a point its been cut off probably. And that is the really weird thing to me...?????

Cheers
 
Old 05-02-2008, 11:37 AM   #4
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
Funny this is, if i run . /etc/rc.status on the command line and then do a ps -ef , it makes no difference to the output what so ever
 
Old 05-02-2008, 11:57 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Dunno. But if you just need the MySQL PIDs why not use 'pgrep -f '/var/lib/mysql/mysqld.pid'' or 'pgrep -f 'n/mysqld_safe ''? Its less errorprone and more efficient than any 'ps|grep -v grep|grep something' combination. For instance:
pgrep -f '/var/lib/mysql/mysqld.pid' >/dev/null 2>&1 || echo "Not running."
or
PID=($(pgrep -f '/var/lib/mysql/mysqld.pid')); [ ${#PID[@]} -le 100 ] && echo "Start some more?"
 
Old 05-02-2008, 12:44 PM   #6
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
No, unfortunately, its not mysql at all, i was just using that as an example. Its almost pleasing however to see that you also can't quite understand the stupid thing its doing. I've got round the problem by just not calling the . /etc/rc.status so early in the script like you normally would, so i've got round the problem now, but i just thought AARRGGHHH and why on earth is it doing that....if anyone knows i'd still be interested to hear an explanation to the reason this is happening?
Cheers

Last edited by helptonewbie; 05-02-2008 at 12:47 PM.
 
Old 05-02-2008, 01:14 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Quote:
Originally Posted by helptonewbie View Post
Its almost pleasing however to see that you also can't quite understand the stupid thing its doing.
Why? I haven't even tried to.
 
Old 05-02-2008, 07:00 PM   #8
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
All i mean is that somone of your experience not being sure of what it is, i like to think i can rule out that its me doing something at least very stupid and simple to fix
 
Old 05-02-2008, 07:39 PM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Humanum errare est, so even if you're an experienced scripting guru chances you overlook something are always there. Besides, my experience means nothing (especially when there's limited information provided).
 
  


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
Linux Boot problem. Extremely weird!!!! ramow Linux - Hardware 3 06-10-2007 10:36 PM
getting a annoying message too much work at interrupt,status 0x01 rhea Linux - Hardware 5 01-25-2006 03:01 AM
weird and annoying font issues dibblethewrecke Linux - Software 0 09-02-2004 01:02 PM
airo: Got weird status 1000 barba Linux - Networking 0 11-11-2003 10:02 AM
Airo: got weird status 1000 bps7j Linux - Networking 0 05-20-2003 10:59 PM


All times are GMT -5. The time now is 01:09 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