3 Replies Latest reply on Jul 22, 2013 6:15 AM by redologger

    nohup sh xxx.sh &  or nohup ./xxx.sh &


      hi guys,


      i couldn't find any unix forum here thus try to post it under this catogory.


      is there a difference between -> nohup sh xxx.sh &  or  nohup ./xxx.sh &


      i did the 2nd one and not too sure my problem is related to the way i executed my command.


      i did a,


      ps -ef | grep xxx.sh


      and did a kill -9 <processID>


      I am expecting a log file but there is no size after i have kill it.

      There is a error saying that there is no such process exist but i am very clear that i have kill the correct one.

      Back in my OEM, is very strange that my session is still running as a difference OS process ID. in the end, i have to kill it from the OEM to stop my sql that is running on the background on my unix server.


      Any advice is appreciated. Thank you.



        • 1. Re: nohup sh xxx.sh &  or nohup ./xxx.sh &



          From my experience there is not much differentiating $nohup sh ... and $nohup ./xxx.sh both of which write to the default $home/nohup.out. Have you tried to point it to a specific out.log file to check if the output is written at all ?

          • 2. Re: nohup sh xxx.sh &  or nohup ./xxx.sh &

            The following should explain it:


            Create a shell script for testing:



            $ echo '#!/bin/bash' > testme

            $ echo 'ps -ef | grep $$ | tac | tail -1' >> testme


            $ cat testme


            ps -ef | grep $$ | tac | tail -1

            Execute the following:


            $ testme

            -bash: testme: command not found


            $ ./testme

            -bash: ./testme: Permission denied


            $ su root


            # cp testme /usr/local/bin

            # exit

            $ testme

            -bash: /usr/local/bin/testme: Permission denied



            $ csh testme

            dude 1922 1895 0 14:26 pts/0 00:00:00 csh testme



            $ chmod u+x testme

            $ ./testme

            dude 1942 1895 0 14:27 pts/0 00:00:00 /bin/bash ./testme

            What does the above output tell us?


            In order to execute a script, similar to a command as shown in 2, it needs execute privileges. The command interpreter (shell) will only execute files in directories according to the $PATH variable. For security reasons, the current path (./) should not be specified in the $PATH environment variable.


            When specifying the script as a shell parameter shown in 3, the script does not need to have execute privileges, and can reside in the current working directory. Also, Irrespective of the shebang or hash-bang defined in the script, the shell interpreter specified at the command prompt will be used for script execution.



            • 3. Re: nohup sh xxx.sh &  or nohup ./xxx.sh &

              just hold on guys, will be testing it out.