suppressing nohup.out file
suppressing nohup.out file
am 15.04.2008 03:46:25 von laredotornado
Hi,
I'm using Fedora Core 6 Linux. When I run the below command
nohup sh /opt/scripts/backup_web.sh &
the file "nohup.out" is produced in the directory where the command is
run. How can I set things up such that the nohup.out file is always
written to /tmp/nohup.out ?
Thanks, - Dave
Re: suppressing nohup.out file
am 15.04.2008 05:23:18 von Ian Petts
> I'm using Fedora Core 6 Linux. When I run the below command
>
> nohup sh /opt/scripts/backup_web.sh &
>
> the file "nohup.out" is produced in the directory where the command is
> run. How can I set things up such that the nohup.out file is always
> written to /tmp/nohup.out ?
The nohup.out file is where the output of your script is going by
default. Redirect it manually if you need the output in another file or
directory:
nohup sh /opt/scripts/backup_web.sh > /tmp/nohup.out 2>&1 &
Regards,
Ian.
Re: suppressing nohup.out file
am 15.04.2008 05:25:21 von Ian Petts
> The nohup.out file is where the output of your script is going by
> default.
I didn't phrase that right. The output of your background process is
going there by default.
Cheers,
Ian.
Re: suppressing nohup.out file
am 15.04.2008 20:05:00 von Chris Mattern
On 2008-04-15, laredotornado wrote:
> Hi,
>
> I'm using Fedora Core 6 Linux. When I run the below command
>
> nohup sh /opt/scripts/backup_web.sh &
>
> the file "nohup.out" is produced in the directory where the command is
> run. How can I set things up such that the nohup.out file is always
> written to /tmp/nohup.out ?
>
"nohup" always sends stdout and stderr to "nohup.out" in the current
directory; this is not configurable. However, if nothing is written
to stdout and stderr, nohup.out is not created. Thus, done this way:
nohup sh /opt/scripts/backup_web.sh >/tmp/nohup.out 2>&1 &
nohup will not produce a nohup.out as you've redirected stdout and
stderr elsewhere.
Note that using generic names like "nohup.out" in /tmp is a bad idea
because another process may be trying to use that name at the same time;
"nohup$$.out" so it gets distinguished with the process number would
be better.
--
Christopher Mattern
NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities
Re: suppressing nohup.out file
am 15.04.2008 22:35:37 von wayne
Chris Mattern wrote:
> On 2008-04-15, laredotornado wrote:
>> Hi,
>>
>> I'm using Fedora Core 6 Linux. When I run the below command
>>
>> nohup sh /opt/scripts/backup_web.sh &
>>
>> the file "nohup.out" is produced in the directory where the command is
>> run. How can I set things up such that the nohup.out file is always
>> written to /tmp/nohup.out ?
>>
> "nohup" always sends stdout and stderr to "nohup.out" in the current
> directory; this is not configurable. However, if nothing is written
> to stdout and stderr, nohup.out is not created. Thus, done this way:
I don't think this is true, at least not on my Linux/Gnu system:
nohup sh -c ':'
still produces an empty nohup.out file.
> nohup sh /opt/scripts/backup_web.sh >/tmp/nohup.out 2>&1 &
Correct, but be careful:
nohup sh -c 'foo >/tmp/nohup.out$$ 2>&1' &
still creates an empty nohup.out in the current directory. Use:
nohup sh -c 'foo' >/tmp/nohup.out$$ 2>&1 &
instead.
>
> Note that using generic names like "nohup.out" in /tmp is a bad idea
> because another process may be trying to use that name at the same time;
> "nohup$$.out" so it gets distinguished with the process number would
> be better.
Excellent advice. Consider using 'mktemp' if available, and
setting 'TMPDIR' to '~/tmp' (which you should create, with
access only to the owner).
-Wayne