executing script not showing up in ps -efx


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting executing script not showing up in ps -efx
# 1  
Old 06-13-2005
executing script not showing up in ps -efx

Hi everyone, here's my problem. I have a script that runs in a infinite loop, repeating the same action in another script every 10 minutes. We need to monitor whether or not this loop script is running and be able to kill it should the need arise. However, the name of the script does not show up in the ps -efx listing, even though it is clearly running in the other window. Is there a way to make the script show itself in the ps -efx output, or get it's process ID?

Thanks!
# 2  
Old 06-13-2005
if you know the pathname to your script....

fuser /path2yourScript

man fuser
# 3  
Old 06-14-2005
Quote:
Originally Posted by herman404
Is there a way to make the script show itself in the ps -efx output, or get it's process ID?

Thanks!
at the start of the script ... get it to write it's PID into a readable file so you'll always know the PID you need to kill later as required ...

Code:
echo $$ > /tmp/script.PID

# 4  
Old 09-10-2005
hi

i am facing the same proble came u suggest me how to read it from a file once u read it and send it to a file
# 5  
Old 09-10-2005
Quote:
Originally Posted by guhas
i am facing the same proble came u suggest me how to read it from a file once u read it and send it to a file
If the filename is as specified above, then
Code:
pid=`cat /tmp/script.PID`

Then use $pid to access the PID. E.g., to kill the process, do kill $pid

But if your system's ps command supports formatted output, with the -o swtich, you can use that instead of saving the PID in a temp file. Try ps -eo pid,args, and search the outpout to see if the name of your script shows up. The importnat thing here is using the args format (as an argument to the -o option). By default, ps outputs the command name as the comm format, which is a shortened form of the command that the system actually executes; the args format gives the full form of the command, which will include the name of the script.

Last edited by hadarot; 09-10-2005 at 02:34 PM..
# 6  
Old 09-10-2005
thanks ...this willwork
but do we have asolution to this without the write read operation from a file

How do we make ps command display the scriptname that is running ?
wh does it show .sh and not complete scripname.sh.
if the scripname was there we could have found it by simple
ps and grep.
someone in the group suggested the reason for not didplaying scripting name
coud be that #!bash is not inlude in the running script /
any solution that way
# 7  
Old 09-11-2005
I would not suggest building a solution that involves a script running an infinite loop. Why not loop until a "stop" file is found, e.g...
Code:
until [[ -f /tmp/stopfile ]]
do
  :
  sleep 600
done
rm /tmp/stopfile

Instead of killing the script, it can be stopped by using:
Code:
touch /tmp/stopfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Ps –efx | grep java6

what does the below command do ps –efx | grep java6 Another question, what is crontab? Please use CODE tags as required by forum rules! (1 Reply)
Discussion started by: houmingc
1 Replies

2. Shell Programming and Scripting

Script showing incorrect output

Hello scripting geeks, I am new to scripting and facing some issues in writing the logic of the script. Request your kind help here Actually when i run a command i get o/p as below o/p : 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 these are hex values i guess...now i want to... (15 Replies)
Discussion started by: kulvant29
15 Replies

3. Shell Programming and Scripting

shell_script showing errors in the below mentioned script while executing in linux

code: IMAGE=$imgvalue; if then echo DO=ABC; elif then echo DO=ETC; elif then echo DO=XYZ; else echo "$imgvalue is unsupported"; exit 1; fi in above script IMAGE=1 , IMAGE=2, IMAGE=3 whatever may be the value i have assigned it's showing only DO=ABC other conditions... (7 Replies)
Discussion started by: saku
7 Replies

4. Shell Programming and Scripting

user attributes not showing when I run the script

I am new to linux/unix scripting and working in one company on linux project. I got a script that when it executes should give us the users atributes showing who is retriving data? the script should show us who are the users reriving information. I ran that script as sudo ./test4 but finding the... (0 Replies)
Discussion started by: starter2011
0 Replies

5. Shell Programming and Scripting

how to check which line of the script is showing the error

how to check which line of the script is showing the error... like -x will print each output in stdout... but want to know exact error line trowing error.. (2 Replies)
Discussion started by: mail2sant
2 Replies

6. Shell Programming and Scripting

Script for showing only selected nodes

Dear all, I am bit confused lately, I have a xmlfile here: file: book.xml <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> ... (2 Replies)
Discussion started by: penyu
2 Replies

7. Shell Programming and Scripting

bash script for showing last users

Hi! I'm new in scripting and I need some help with one simple script. I have to write a program that shows in a predetermined period (using "last" command), to draw up a list of users who have used the machine during this period. Each user to indicate how many sessions it has been during this... (9 Replies)
Discussion started by: vassu
9 Replies

8. Shell Programming and Scripting

Showing off my rsync-to-USB script

Thank you all for helping me figure out how to manage spaces in paths. The following script is the result. The script uses rsync to backup files to a USB device. Special thanks to Scrutinizer:b:. rsync2u is a free menu-driven script. Down load the script from... (7 Replies)
Discussion started by: wolfv
7 Replies

9. Shell Programming and Scripting

Script is showing abnormal behavior...

Hi, facing unusual problem, below are 2 same scripts, one is working and other is not. please help --- THIS SCRIPT IS WORKING FINE!!!! #! /bin/sh phone=`grep "<phone>" data.xml | sed 's:<phone>::;s:</phone>::'` echo "Phone Number is:"$phone repnum=554156 cat data.xml | sed -e... (3 Replies)
Discussion started by: Prateek007
3 Replies

10. Shell Programming and Scripting

not showing restore information while run script

Hello, I have the following script to restore file and grep information. However, once it restore file, it showing a lot useless information and different to check which file have the statement "John price $200". Can I not show any information while running script. It only show..when found the... (1 Reply)
Discussion started by: happyv
1 Replies
Login or Register to Ask a Question