Operating System - HP-UX
1846554 Members
2723 Online
110256 Solutions
New Discussion

nohup - is it working or not???

 
SOLVED
Go to solution
Peter Gillis
Super Advisor

nohup - is it working or not???

HI,
ux-op 11.00; rp2470 machine.
Is there a way to tell if the nnohup command is working properly or not. Are there stty setting s or such that need to be in place?
I have issued a nohup cmd and immediatley it appears the job is being stopped. would someone explain it and how I can stop this from happening. a copy of the command and output follows:
# ps -ef|grep dsm

root 8814 8793 0 08:26:40 pts/tb 0:00 grep dsm (check job not running)
#nohup dsmc schedule >> /dev/null &
[1] 9817 (start the job)

# ps -ef |grep dsm
root 9821 8793 0 09:49:58 pts/tb 0:00 grep dsm
root 9817 8793 0 09:49:51 pts/tb 0:00 dsmc schedule
[1] + Stopped (SIGTTIN) nohup dsmc schedule >> /dev/null &

thanks,
Maria.
10 REPLIES 10
malay boy
Trusted Contributor
Solution

Re: nohup - is it working or not???

the one thing to check here whether the job dsmc schedule is having problem or not.You could spool any error from 'dsmc' job to a file,view it and check whether any error or not.

#nohup dsmc schedule 2>/tmp/error_log&
There are three person in my team-Me ,myself and I.
John Dvorchak
Honored Contributor

Re: nohup - is it working or not???

Maria, your command, ps -ef did stop because it was finished. It ran and displayed the results. Maybe you don't know what the nohup is really used for. Let's say that you have a job that either you don't have time to wait and see the output, like creating an Ignite tape, or you need to do something else while the job runs. Then you would use nohup to keep the job running even if you log off of the system and go home for the evening. Then you can come in the next day and look at the output from your job in the file nohup.out that was created in the directory that you ran it from.

A good way to test it is to cd to your home directory. Then start a job that takes a while. Let's do a find on a file that you know exists but will take the system some time to find:

find / -name syslog.log

Now to use nohup issue the command like this:

nohup find / -name syslog.log &

The ampersand (&) tells the process to run in the background. In a couple of minutes you will see the "Done xxxx" on the screen where xxxx is the PID of the find command. Then look at nohup.out and you will see the results of the find command. You can even logout before the find is finished and it will still put anything that would have gone to the screen into the nohup.out file.

Good luck
If it has wheels or a skirt, you can't afford it.
Bill Hassell
Honored Contributor

Re: nohup - is it working or not???

nohup's sole purpose is to protect a program from the SIGHUP or SIGTERM signal which occurs when a session is disconnected or terminated. It's primary usage is to allow a proram to continue running in the background after the user logs out. As shown in the example, you can run a program using nohup and place the program in the background. At that point, you can log out and the program continues to run.

To test, try this:

nohup sleep 200 &

Now, logout and login again. Using ps, you'll see the sleep command still running. The termination signal was trapped by nohup and not sent to the sleep process. Now run the same command without nohup:

sleep 200 &

and logout and login again. The sleep command will be gone because the shell will send a terminate signal to all child processes.


Bill Hassell, sysadmin
John Payne_2
Honored Contributor

Re: nohup - is it working or not???

We have an issue open on nohup with HP. They are working on a defect fix for us. I think they are several weeks out still. We are not the only shop to see this, and the engineers have duplicated the problem, whatever it is.

For instance, if we issue a 'nohup sar 1 90 &' and exit our session, the nohup dies at the exit.

Hope it helps, and I'll try to keep you posted.

John
Spoon!!!!
Peter Gillis
Super Advisor

Re: nohup - is it working or not???

Apologies for my note being unclear. I do understand how to use the nohup cmd - my query was more to the fact that each time I was starting the dsmc process, the system came immediatly back and said the process had stopped. This I did not want to happen. The process is supposed to keep going until instructed to stop by a user. Thank you all for your responses though.
The issue has been cleared now - with the help of Malay's reply. I was supposed to have another process started at the same time to ensure password creatoin/generation was checked for and implemented - no waiting for input from keyboard.!! (Keep it simple, stupid - has proudly become my motto!!!!!)
Thanks everyone.
Gary Yu
Super Advisor

Re: nohup - is it working or not???

Hi John,

we had the same problem, nohup can't keep a sar session, which make it hard to collect sar data for a long period of time. Anybody else have the same problem? please share your work around ...

thanks,
Gary
John Payne_2
Honored Contributor

Re: nohup - is it working or not???

Until HP comes out with the fix for the defect fix they are working on, we are waiting for them. A workaround that seems to work is to log in, open a new shell, (type 'sh'), and do your nohup. Then exit that shell. The nohup seems to work at that point.

I'll update when I get a chance...

Hope it helps
John
Spoon!!!!
Gary Yu
Super Advisor

Re: nohup - is it working or not???

Yes John, I tried the new shell way, it works fine, thanks for the information!

Gary
Animesh Chakraborty
Honored Contributor

Re: nohup - is it working or not???

I am also facing the same problem.

My scripts is like this

#!/bin/csh
setenv GWCONFIG $HOME/P1P_mailconfig
nohup mlunxsnd -actap1.mlunxsnd.p1p001 -gctap1 -xsapgw00 &

the mlunxsnd program should run always to enable sap to send mails.
But it keeps on dying.
Did you take a backup?
Bill Hassell
Honored Contributor

Re: nohup - is it working or not???

You'll have to determine the reason that it is dying. It likely has nothing to do with nohup but that the program is missing some enviromental settings. This is a very common oversight with cron jobs as cron (see the man page) does NOT provide the user's login environment. Check that the process runs OK in a login environment, then use the env command to list what the program see in a login environment. Then for cron, provide the important env values as part of the script.


Bill Hassell, sysadmin