![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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! |
|
||||
|
Quote:
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.. |
|
||||
|
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 |
|
|||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|