Operating System - HP-UX
1833828 Members
2105 Online
110063 Solutions
New Discussion

Re: Renaming a shell script's process name

 
SOLVED
Go to solution
Olivier Masse
Honored Contributor

Renaming a shell script's process name

I have to run a shell script that stays active for a long, long time. But when I run top, ps, glance, etc I only see "ksh" as the process name. I would prefer seeing something more significant. I'd like to have it renamed.

The only way I know how to do this is to start it from a C program with a fudged exec() call. That's not nice. Is there any other easy way to do this?

Thanks
9 REPLIES 9
Florian Heigl (new acc)
Honored Contributor

Re: Renaming a shell script's process name

Hmm....

would the following be enough?

root xxxx xxxx 11 17:03:42 pts/xx 0:00 /bin/sh ./change_timeout.sh

That's what I get when I call my change_timeout.sh which has an interpreter set in it's first line (#!/bin/sh).
yesterday I stood at the edge. Today I'm one step ahead.
Olivier Masse
Honored Contributor

Re: Renaming a shell script's process name

Unfortunately it doesn't do what I want. seem to work.

I can see it in "ps" as command-line options but top still shows only "ksh".

BTW I have the bang #!/bin/ksh at the top.
Sandman!
Honored Contributor

Re: Renaming a shell script's process name

Are you exec'ing ksh from within your shell script...so that your current shell's invocation is replaced by ksh???
Olivier Masse
Honored Contributor

Re: Renaming a shell script's process name

> Are you exec'ing ksh from within your
> shell script...so that your current
> shell's invocation is replaced by ksh???

Yes, since there is a bang at the start.

Sandman!
Honored Contributor

Re: Renaming a shell script's process name

Still not clear about this issue...could you provide the command you're trying to run.

thx

Alan Meyer_4
Respected Contributor

Re: Renaming a shell script's process name

I'm just throwing an idea out there and I havn't tested it....

how about making a copy of ksh and name it "scriptwrap" or something else meaningful and then run your job/script from inside "scriptwrap" shell???
" I may not be certified, but I am certifiable... "
TwoProc
Honored Contributor
Solution

Re: Renaming a shell script's process name

To build a bit on Alan's idea: How about just a symbolic link into the current directory (or your favorite bin directory) to ksh and call it something else?

$ cat testit
#!/home/bo/myshell
sleep 60

$ cd ~
$ ls -al myshell

lrwxr-x--- 1 bo users 8 Sep 12 11:06 myshell -> /bin/ksh

$ ./testit &

I just tried it, and it works great with the ps -ef | grep command combo

$ ps -ef | grep -v grep | grep myshell

bo 15716 15187 0 11:06:53 pts/4 0:00 /home/bo/myshell ./testit
We are the people our parents warned us about --Jimmy Buffett
Olivier Masse
Honored Contributor

Re: Renaming a shell script's process name

John's solution did the trick.

Thanks to everybody.
Olivier Masse
Honored Contributor

Re: Renaming a shell script's process name

.