Operating System - HP-UX
1819824 Members
3086 Online
109607 Solutions
New Discussion юеВ

nohup.out does not get created

 
SOLVED
Go to solution
Archana Prasad
Occasional Advisor

nohup.out does not get created

Hi,

I have written a bourne shell script which starts a process. Extract is:
-
cd $BIN
nohup $BIN/startmyprog
cat nohup.out
-
--
The problem is when I schedule this to run through either crontab or at, I get an error message: nohup.out not found. The nohup.out is necessary since all the application log gets sent to this file.

However, when I execute this via command line manually, a nohup.out gets created in $BIN subdirectory.

Could anyone suggest a method where I can automatically schedule this script such that it creates the nohup.out?

Thanks a lot!!
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor

Re: nohup.out does not get created

If nohup cannot write in the current directory then it attempts to create nohup.out in the HOME directory. You should probably first cd to a known writable direcory then execute the nohup.

Clay
If it ain't broke, I can fix that.
Brant Evans
Occasional Advisor
Solution

Re: nohup.out does not get created

you could specify the complete path for the output to go such as

nohup $BIN/startmyprog >/tmp/nohup.out 2>&1

This will send both standard out and standard error to the /tmp/nohup.out file.

Each time the command is run the /tmp/nohup.out file will be truncated. If you want the results from every run to be appended to the end of the /tmp/nohup.out file then you can use '>>' instead of just '>'.

Also, the file can be any name that you like.
Mark Chandler_1
Advisor

Re: nohup.out does not get created

Are you scheduling this script as root?
Have you checked to see what the return code is after that line has completed? That might give you a clue as to whether nohup working correctly.
Andre Blanchette
Occasional Advisor

Re: nohup.out does not get created

Have you put :

#!/bin/ksh


at the begining of script so it can run with cron. Could also run .profile to get your variables set.

regards.
becoming HP knowlegable person?
Archana Prasad
Occasional Advisor

Re: nohup.out does not get created

I redirected the output specifically to nohup.out and it seems to work. Please accept my heartfelt thanks!!

Magdi KAMAL
Respected Contributor

Re: nohup.out does not get created

Hi,

Your commands will be executed correctly if your BIN variable is well setting.

But when you schedule it in crontab, you MUST include your environment variable in the crontab by executing your profile as your first command and continue with the rest like:

. //.profile
cd $BIN
nohup $BIN/startmyprog
cat nohup.out
-

This will solve your problem.