|
Home > Archive > Unix Shell > January 2006 > nohup and commands within scripts
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
nohup and commands within scripts
|
|
|
| Hi. If this question belongs elsewhere, please let me know.
I have a bash script foo that I start like this:
nohup foo > foo.log 2>&1 &
I'm logged into a GNU/Linux box from Windows XP.
I use putty as my command window.
The problem is inside foo I have cvs commands. When I lose my wireless network, the putty window dies and the cvs command dies as well. (Is there a way to make putty's behavior not so fatal?) I
would have thought the cvs command would be running under the aupices of the "nohup foo", and thus be immune to hangups.
One more wrinkle: I put the cvs command into a variable called "cmd" and run it in foo like this:
eval $cmd
Is the eval the problem? If not, do I just need to prepend "nohup" to all the commands I put in the cmd variable before I execute them? Or what?
Thanks.
| |
| JP Vossen 2006-01-29, 9:31 pm |
| RR wrote:
> Hi. If this question belongs elsewhere, please let me know.
>
> I have a bash script foo that I start like this:
>
> nohup foo > foo.log 2>&1 &
>
> I'm logged into a GNU/Linux box from Windows XP.
>
> I use putty as my command window.
>
> The problem is inside foo I have cvs commands. When I lose my
> wireless network, the putty window dies and the cvs command dies as
> well. (Is there a way to make putty's behavior not so fatal?) I
> would have thought the cvs command would be running under the aupices
> of the "nohup foo", and thus be immune to hangups.
Take this with a grain of salt, as I don't really use nohup (you'll see
why in a second). My understanding is that when your terminal dies it
takes all your processes with it, as you know since you are already
using nohup. But if your command produces output, which cvs does unless
you take steps to prevent it, and your terminal is gone, the process
will be suspended. Have you looked for a bunch of stale processes
hanging around? I've also never quite figured out how to "re-attach" to
the process when I log back in.
HOWEVER, I never spent much time on the issue, because the solution to
that and much more is to use the excellent GNU screen program. Screen
is a terminal multiplexer, but it also allows you to disconnect sessions
and reconnect later. I use it all the time, and when my VPN dies I just
reconnect and I'm back in business. It's really great.
See http://jmcpherson.org/screen.html and
http://www.gnu.org/software/screen/. It comes with most or all Linux
distros, and is available one way or another for just about any Unix or
Unix-like OS you can think of.
> One more wrinkle: I put the cvs command into a variable called "cmd"
> and run it in foo like this:
>
> eval $cmd
That should be fine, though unless you are re-using the CVS command it
might be overkill.
> Is the eval the problem? If not, do I just need to prepend "nohup" to
> all the commands I put in the cmd variable before I execute them? Or
> what?
No clue, just use screen.
HTH,
JP
----------------------------|:::======|-------------------------------
JP Vossen, CISSP |:::======| jp{at}jpsdomain{dot}org
My Account, My Opinions |=========| http://www.jpsdomain.org/
----------------------------|=========|-------------------------------
You used to have to reboot the Windows 9.x series every couple of days
because it would crash. Now you have to reboot Windows 200x or XP
every month on 'Patch Tuesday.' How is that better or more stable?
|
|
|
|
|