1753903 Members
10166 Online
108810 Solutions
New Discussion юеВ

Nohup question

 
SOLVED
Go to solution
Carlo Henrico_1
Regular Advisor

Nohup question

I am probably just doing something stupid, but if I submit a job as follows:

nohup jobname parameter_file &

and I exit, it says there are running jobs. If I then exit again it terminates the jobs. What should I do to submit a job allowing me to exit my session without the job terminating?

Thanks

Carlo
Live fast, die young - enjoy a good looking corpse!
11 REPLIES 11
Thierry Poels_1
Honored Contributor

Re: Nohup question

Hi,
your shell warns you that you have running jobs. But when you exit your nohup jobs should keep on running. No special configuring required.
Put a sleep command in your script, and "ps -ef | grep sleep" after exiting should show you job.
good luck,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Vincent Stedema
Esteemed Contributor

Re: Nohup question

Are you 100% sure that the job terminates when you exit? As far as I can see, you're not doing anything wrong.

Vincent

Carlo Henrico_1
Regular Advisor

Re: Nohup question

I have just re-tested it (there are two jobs) and they definately do terminate. They are both C++ programs developed in-house. Maybe there is something special which should be included in the code?

Carlo
Live fast, die young - enjoy a good looking corpse!
Carlo Henrico_1
Regular Advisor

Re: Nohup question

...maybe I should pose this question under the "Languages" forum?

Carlo
Live fast, die young - enjoy a good looking corpse!
Vincenzo Restuccia
Honored Contributor

Re: Nohup question

Verify the priority of the job with ps -elf|grep job,and list it with nice (see man nice).
Carlo Henrico_1
Regular Advisor

Re: Nohup question

Vincenzo

Any idea what I should do with its nice value once I know it?

Carlo
Live fast, die young - enjoy a good looking corpse!
Thierry Poels_1
Honored Contributor
Solution

Re: Nohup question

Hi,
I've never started a C-prog through nohup directly. I've always used a surrounding shell script.
Maybe, just maybe, a C-prog stops if it's detached from it's parent shell; just a (very very) wild guess.
Try putting a sleep command in a shell script, start it through nohup, logoff, and check if that keeps running. If so, put your prog in a shell script.
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Laurent Paumier
Trusted Contributor

Re: Nohup question

Watch the file nohup.out for error messages.

You may also try redirecting stdin :
nohup your_prog
Stefan Schulz
Honored Contributor

Re: Nohup question

I had a problem with a programm which checked if the parent process was still running. This programm also died if i loged out, even when using nohup.

Luckily this programm had an option to disable this check for the parent process.

But i think all you have to do is to make sure that there is a process alive when you logout.

So i would suggest you write a small wraperscript which calls your programm and nothing more. Then you start this script with nohup. Then your script doesn't die and you programm should find its parent process still running.

Hope this helps. Stefan
No Mouse found. System halted. Press Mousebutton to continue.