nohup retuncode
Hy
Can sombody tell me if it's possible to get the returncode from a script that is launched with nohup... example script test.sh #!/bin/sh echo test exit 8 script launch test nohup test.sh 1>test.log 2 >1 & rc=$? echo $rc >rc if i try so a don't get the return code because nohup run the script test.sh in other shell, is there smome way to do this ??? sorry for my bad english |
Your English is fine.
The issue is that you're sending this a background process with the ampersand ("&"). The nohup just tells it not to hang up when the terminal goes away so doesn't really have anything to do with backgrounding it. By definition any process started with "&" will give the shell that started it a return code of 0 (success) because the "&" has told the starting shell not to wait for return status. What you could do is have a another script that executes test.sh and then records its return code. Within that script you would NOT background test.sh. However you WOULD background that new script. It would be simpler though to just incorporate whatever action you want to take within test.sh itself at the point it is doing its return code. If you just want to know what it did you can just have it output the return code to a file then check that file manually. You could even have it redirect its output to your live terminal but if you're doing that you shouldn't do "nohup" as it will have issues if it tries to output to the terminal and you've logged out and closed the terminal. |
Thanks, your solution works fine.
Christian |
All times are GMT -5. The time now is 03:24 PM. |