Operating System - HP-UX
1832890 Members
2704 Online
110048 Solutions
New Discussion

problem running script in background

 
George_Dodds
Honored Contributor

problem running script in background

Hi all

I'm running the following commands

nohup ./runimpdb pcs > /dev/null 2>&1 &

this should run the script in the background so it doesnt matter when my remote connection times out.

But if i press any key the process terminates and the same when my connection times out.

What am i missing here?

Cheers

George
8 REPLIES 8
Richard Hepworth
Esteemed Contributor

Re: problem running script in background

George,

Are you sure there are no errors in the script? does it run fine in the foreground?
George_Dodds
Honored Contributor

Re: problem running script in background

The script is fine it's to refresh an informix db.

It runs fine in the foreground.
Richard Hepworth
Esteemed Contributor

Re: problem running script in background

have you tried redirecting stdout and stderr to a file instead of /dev/null and see if that gives any clues as to why the script is exiting? The command you are using should work providing the script is good
V. Nyga
Honored Contributor

Re: problem running script in background

Hi,

the command will always have the father process id (PPID) of the session where you start the command. So if this session is quited, then all children processes also will quit.
You have to start the process with father process id '1' (if possible).

For your other problem - how do you connect to the ws? Which term setting?

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
Laurent Menase
Honored Contributor

Re: problem running script in background

Hi George,
are you sure that your process doesn't make a "read"?

else you should redirect input too.
Patrick Wallek
Honored Contributor

Re: problem running script in background

I would take a slightly different approach to this.

Step 1) Create a small script file with your command line and make sure it is executable by you. I would probably do something like:

# cat runimp
/path/to/runimpdb pcs > /path/to/logfile 2>&1

Step 2) Use 'at' to run it.
# at -f /path/to/runimp now

I find 'at' much easier to deal with and I don't have to worry if my session dies. The script will keep running. By redirecting to a logfile you can monitor progress as well by doing a 'tail -f /path/to/logfile' (assuming the process sends useful output to the logfile).
Dennis Handly
Acclaimed Contributor

Re: problem running script in background

As Laurent suggests, it is probably trying to read from your terminal. You need to also use:
< /dev/null

(This seems similar to the remsh -n issue.)

And as Richard said, you might want to look at the output, there may be a message.
Procnus
Frequent Advisor

Re: problem running script in background

Is it possible that it is a do loop and a sleep nn line is missing?