1

I have a shell script which does somewhat simple.

#!/bin/sh
do something boring...

When I execute the shell script like this,

$ nohup sh mysh.sh > /null/dev/ 2>&1 &

I see there are two processes listed.

$ ps -ef | grep mysh
... xxxxx 1     ... sh mysh.sh // same xxxxx
... yyyyy xxxxx ... sh mysh.sh // same xxxxx

Is this normal?

1

I just recreated what you have here and replaced do something boring... with sleep 10000 and did not have this happen. I believe that you are doing something which uses fork() or clone() to create a child process. I had suspected that nohup ran the process as a child process but that does not appear to be the case.

1

As you can see, yyyyy is the child process of xxxxx. It is perfectly normal that the same shell script be executed inside "mysh.sh" which will result in such a scenario.

Are you directly/indirectly invoking mysh.sh inside the script? That's the only way I could think this will ever happen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.