The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
not showing restore information while run script happyv Shell Programming and Scripting 1 11-20-2007 04:05 AM
executing script big123456 Shell Programming and Scripting 1 06-03-2005 08:32 AM
RSH use for executing a script frustrated1 Shell Programming and Scripting 6 10-02-2003 09:24 AM
Executing ksh script from cgi hodges Shell Programming and Scripting 1 05-27-2003 11:57 AM
Executing Ps in script Claude Shell Programming and Scripting 1 11-22-2001 02:01 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-13-2005
herman404 herman404 is offline
Registered User
  
 

Join Date: Feb 2005
Location: London, United Kingdom
Posts: 4
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 (permalink)  
Old 06-13-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
if you know the pathname to your script....

fuser /path2yourScript

man fuser
  #3 (permalink)  
Old 06-14-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
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 (permalink)  
Old 09-10-2005
guhas guhas is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 22
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 (permalink)  
Old 09-10-2005
hadarot hadarot is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 33
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 (permalink)  
Old 09-10-2005
mpauls mpauls is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 4
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 (permalink)  
Old 09-11-2005
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
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

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0