Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell script process name

Status
Not open for further replies.

oceandeep

IS-IT--Management
Jul 6, 2000
69
GR
Hi,

when I run a shell script, ps -e will only show something like -sh, which is quite confusing if I run some other scripts at the same time. Is there a way that I can list the script with its name?

Thanks!
 
i tried, and i am using bash, but still the same, i couldn't see the script name listed in the process list.
 
Are you on Solaris? What version? Seems to work fine for me:

[tt]$ cat sleepy.sh
#!/bin/sh
sleep 300
$ ./sleepy.sh &
[1] 2456
$ ps -ef | grep sleepy
scott_ro 2459 2395 0 10:20:25 pts/1 0:00 grep sleepy
scott_ro 2456 2395 0 10:20:22 pts/1 0:00 /bin/sh ./sleepy.sh
$[/tt]

The only other thing I can think of is if there is a long path name to your shell script the command name might be truncated in the ps -ef listing, in which case try using /usr/ucb/ps uwwwax instead, for extra output.

Annihilannic.
 
i think i know problem, i missed the line #!/bin/sh
but if in that case, how to find out the process?
 
Hmm... interesting, I didn't know that happened if you left out the shebang line.

You could do an fuser on the script file to find the process ID?

[tt]$ cat sleepy.sh
sleep 300
$ ./sleepy.sh &
[1] 20110
$ fuser sleepy.sh
sleepy.sh: 20110o
$ PID=`fuser sleepy.sh 2> /dev/null`
$ echo $PID
20110
$[/tt]


Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top