AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  nim script & nohup problem

    Posted Wed September 15, 2010 10:36 AM

    Originally posted by: lnetju


    Hello,

    I wrote a NIM post-installation script, which launch a background command with nohup :

    nohup command &

    The problem is that the nim script waits the end of the nohup command to finish.

    How can i fix this problem?

    Thanks you.
    #AIX-Forum


  • 2.  Re: nim script & nohup problem

    Posted Wed September 15, 2010 10:45 AM

    Originally posted by: orphy


    Try putting the command with nohup inside a script and add "exit 0" at the end of the script. You can then nohup the script instead.
    Orphy
    #AIX-Forum


  • 3.  Re: nim script & nohup problem

    Posted Wed September 15, 2010 11:20 AM

    Originally posted by: lnetju


    Thanks you for the response.

    But it doesn't work!

    The NIM script waits the end of the nohup command!

    For example :
    My NIM script :
    #!/usr/bin/ksh

    nohup /toto.ksh < /dev/null > /dev/null 2>&1
    exit 0

    The /toto.ksh on the client :
    #!/usr/bin/ksh

    sleep 20
    exit 0

    The NIM script ends only when the "sleep 20" ends.
    #AIX-Forum


  • 4.  Re: nim script & nohup problem

    Posted Wed September 15, 2010 12:49 PM

    Originally posted by: orphy


    It waited for the sleep since you didn't use an & at the end nohup in the nim script. Try something like this and see if it works.

    nohup /toto.ksh &

    You can also try using "at now" with something like this instead of nohup.

    at now <<EOF
    /toto.ksh
    EOF
    Orphy
    #AIX-Forum


  • 5.  Re: nim script & nohup problem

    Posted Thu September 16, 2010 04:10 AM

    Originally posted by: lnetju


    The solution with "at now" works fine.

    Thanks you!!!
    #AIX-Forum


  • 6.  Re: nim script & nohup problem

    Posted Thu September 16, 2010 08:56 AM

    Originally posted by: orphy


    That's good to hear. Just remember that you will likely need to redirect the output of the script (inside the at block) to /dev/null or a file. If not, whichever user you run this as would probably get an email of the output from the script. If no one checks the mails regularly, the mbox will get bigger and bigger.
    Orphy
    #AIX-Forum