Unable to grep the process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to grep the process
# 1  
Old 12-05-2016
Tools Unable to grep the process

I have user1 run a script called logginexpert.sh while has this line of code

Code:
sleep 888

I then login to another putty session with another user2 and try to grep for the logginexpert.sh process using

Code:
ps -ef | grep ex

Code:
SunOS mymac 5.11 11.2 sun4u sparc SUNW,SPARC-Enterprise

But, i dont get any results when i was expecting it to show the process logginexpert.sh that was started by user1.



Can you please help me fix this problem ?
# 2  
Old 12-05-2016
Does it show up in the long list, when not grepping?
# 3  
Old 12-05-2016
Tools

Quote:
Originally Posted by RudiC
Does it show up in the long list, when not grepping?
Not sure what long list is but i grep for the entire script name and it still does not showup in the results.

Code:
ps -ef | grep logginexpert.sh
No results Found.

I also tried

Code:
 ps -ef >/tmp/tmp.tmp
grep ex /tmp/tmp.tmp
No results Found.


Last edited by mohtashims; 12-05-2016 at 02:47 PM..
# 4  
Old 12-05-2016
Can you even SEE the process using ps -ef

Do not use more or grep. Why? If the path to the file is part of the ps display for
Code:
 logginexpert.sh

then it may include the entire path - which can exceed what ps will show - too many characters.

PS: on Solaris pgrep may be your better choice for this kind of thing.
# 5  
Old 12-05-2016
Quote:
Originally Posted by jim mcnamara
Can you even SEE the process using ps -ef

Do not use more or grep. Why? If the path to the file is part of the ps display for
Code:
 logginexpert.sh

then it may include the entire path - which can exceed what ps will show - too many characters.

PS: on Solaris pgrep may be your better choice for this kind of thing.
location of logginexpert.sh is /tmp/logginexpert.sh

Code:
 ps -ef | pgrep /tmp/testbkpme.sh
No results Found.
ps -ef | pgrep bk
No results Found.

ps -ef also does not show /tmp/logginexpert.sh but I'm able to grep the process by the pid but not with the script name.

Putty Session 1:
Code:
/tmp/logginexpert.sh &
[1]     4627

Putty Session 2:
Code:
You have new mail in /var/mail/user2
ps -ef | grep 4627
    user1 4627 10477   0 13:54:09 pts/11      0:00 sleep 888
ps -ef | grep ex
    user2 5650 15730   0 13:54:27 pts/16      No results Found.

So definitely the process is running.

---------- Post updated at 03:12 PM ---------- Previous update was at 02:36 PM ----------

Also ps -ef does not show the name of the script but i see this sleep 888 in the results.

Can you please help sort this out ? i want to grep by name of the script not by its contents.

Last edited by mohtashims; 12-06-2016 at 02:18 AM..
# 6  
Old 12-06-2016
Display the processes of user1
Code:
ps -fu user1

If "sleep" is spawned by the script then look for its parent process (given in column 3).
Maybe your grep is forged?
Code:
/bin/ps -fu user1 | /bin/grep ex

grep can match its own argument in the ps list. pgrep avoids that.
Code:
pgrep -u user1 ex

# 7  
Old 12-06-2016
Bug

The issue is not to do with different users or different putty session. Becoz i Cannot find i.e grep for the logginexpert.sh script with the same user in the same putty session.

Also,

Code:
  /bin/ps -fu | /bin/grep ex
  /bin/ps: option requires an argument – u
  
  pgrep -u user1  ex
  No results Found.

/bin/ps fu  | /bin/grep ex
/bin/ps: illegal option -- f

/bin/ps u   | /bin/grep bk
Result not Found.

Let me know what are we missing ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to grep using wildcard in a file.

I wish to check if my file has a line that does not start with '#' and has 1. Listen and 2. 443 echo "Listen 443" > test.out grep 'Listen *443' test.out | grep -v '#' Listen 443 The above worked fine but when the entry changes to the below the grep fails... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Shell Programming and Scripting

Unable to do grep in a script

Hi, I am trying to grep a filename from a script after taking the file name and other variables as keyboard input .When I run the grep command with the same filename on the prompt, it runs fine, but it is either not giving me the correct output or not running at all from the script using the... (13 Replies)
Discussion started by: dsid
13 Replies

3. UNIX for Dummies Questions & Answers

Unable to grep

I have a file with 2 lines of code Rome is in Romeo Romeo is in Rome How do I grep, so that only last line would be the outcome. sample output Romeo is in Rome I have tried with all possible greps but its resulting in both the lines in output. Please help. (6 Replies)
Discussion started by: gotamp
6 Replies

4. UNIX for Dummies Questions & Answers

cron job is unable to process

Hi All, I have got a shell script that excutes some job and mails me the output as an attachment. While running the script manually, its perfect. when i am scheduling the job through crontab, i am getting the mail. but the attachment but this is a blank file. after the scheduler run, i can... (2 Replies)
Discussion started by: gotam
2 Replies

5. Shell Programming and Scripting

Unable to Kill the process

Hi Guys, I am unable to kill the process . and same process is running so many times. If i am trying to kill once again it restarting/kicked off again. and now i am unable to login . i am getting error message like "error -cannot fork too many process " i know when we ll get this message... (8 Replies)
Discussion started by: kartheek
8 Replies

6. Shell Programming and Scripting

grep the process id and kill all the filtered process

Hi I want to write a shell script which can find the process id's of all the process and kill them eg: ps ax | grep rv_ 3015 ? S 0:00 /home/vivek/Desktop/rv_server 3020 ? S 0:00 /home/vivek/Desktop/rv_gps 3022 ? S 0:00 /home/vivek/Desktop/rv_show ... (7 Replies)
Discussion started by: vivek_naragund
7 Replies

7. BSD

Unable to process from lines (envelopes)

Hi, Some of the users on my freebsd server are getting the "unable to process from lines" error when accessing their mailbox. I've checked their mailbox and found that there was a blank line at the top of the mailbox. Everytime i remove it, it appears again sometime later. I've tried... (1 Reply)
Discussion started by: sc_king
1 Replies

8. HP-UX

Unable to kill a process

problem. (2 Replies)
Discussion started by: pvamsikr
2 Replies

9. Shell Programming and Scripting

unable to grep the following pattern

I have the following line in file1 elif ; then now if i try to grep this using following command grep -e "elif ; then" file1 it is showing nothing... how to grep such patterns (2 Replies)
Discussion started by: suri
2 Replies

10. Shell Programming and Scripting

Unable to kill sleeping process

Hi, I'm trying to delete a sleeping process (parent ID is not 1) with "kill -9" command by the owner of the process (infodba) but it doesn't get killed. Is there any way of killing this process without killing the parent process or rebooting? (I'm using HP Unix B.11.11) $ ps -eflx | grep... (0 Replies)
Discussion started by: stevefox
0 Replies
Login or Register to Ask a Question