Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why is a nohup.out file created for this command?

9 views
Skip to first unread message

Wolfgang Meister

unread,
May 20, 2008, 4:43:39 PM5/20/08
to
When I perform the following command:

nohup sh -c "echo `date` >>logfile.txt && ls -l >>logfile.txt && echo `date` >>logfile.txt" &

or - alternatively - without the trainling "&":

nohup sh -c "echo `date` >>logfile.txt && ls -l >>logfile.txt && echo `date` >>logfile.txt" &

I always got a response:

nohup: appending output to `nohup.out'

file nohup.out is created but always empty. logfile.txt is filled as intended.

How can I suppress the nohup.out message and the nohup.out file creation?

Wolfgang

John Gordon

unread,
May 20, 2008, 5:00:14 PM5/20/08
to
In <483337fb$0$6556$9b4e...@newsspool3.arcor-online.net> wmei...@hotmail.com (Wolfgang Meister) writes:

> When I perform the following command:

> nohup sh -c "echo `date` >>logfile.txt && ls -l >>logfile.txt && echo `date` >>logfile.txt" &

> or - alternatively - without the trainling "&":

> nohup sh -c "echo `date` >>logfile.txt && ls -l >>logfile.txt && echo `date` >>logfile.txt" &

Those commands are exactly the same. Did you intend them to be different?

> How can I suppress the nohup.out message and the nohup.out file creation?

Redirect the output to a file instead of letting it display on the terminal.

--
John Gordon A is for Amy, who fell down the stairs
gor...@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

Bill Marcum

unread,
May 20, 2008, 6:08:27 PM5/20/08
to

The nohup command sees the arguments 'sh' '-c' and a long quoted string.
To suppress nohup.out, you need to redirect nohup's output.

Marcel Bruinsma

unread,
May 20, 2008, 6:26:04 PM5/20/08
to
In article <483337fb$0$6556$9b4e...@newsspool3.arcor-online.net>,
Wolfgang Meister wrote:

> nohup sh -c "echo `date` >>logfile.txt && ls -l \
> >>logfile.txt && echo `date` >>logfile.txt" &

Redirect std{in,out,err} of nohup:

$ nohup sh -c 'date; ls -l; date' </dev/null >>logfile.txt 2>&1 &

h.stroph

unread,
May 20, 2008, 9:10:06 PM5/20/08
to
"Wolfgang Meister" <wmei...@hotmail.com> wrote in message
news:483337fb$0$6556$9b4e...@newsspool3.arcor-online.net...

> How can I suppress the nohup.out message and the nohup.out file creation?

2>/dev/null will suppress the message, but you can't prevent hohup.out ...
just ignore it.


Joachim Schmitz

unread,
May 21, 2008, 2:23:30 AM5/21/08
to
Redirect stderr too
nohup sh -c "echo `date` >>logfile.txt 2>&1 && ls -l >>logfile.txt 2>&1 &&
echo `date` >>logfile.txt 2>&1" &

>
> Wolfgang
Bye, Jojo


Dan Mercer

unread,
May 21, 2008, 6:15:10 PM5/21/08
to
"Wolfgang Meister" <wmei...@hotmail.com> wrote in message
news:483337fb$0$6556$9b4e...@newsspool3.arcor-online.net...
> When I perform the following command:
>
> nohup sh -c "echo `date` >>logfile.txt && ls -l >>logfile.txt && echo
> `date` >>logfile.txt" &
>
> or - alternatively - without the trainling "&":
>
> nohup sh -c "echo `date` >>logfile.txt && ls -l >>logfile.txt && echo
> `date` >>logfile.txt" &
>
> I always got a response:
>
> nohup: appending output to `nohup.out'
That's because you haven't redirected stdout. The sh command you call
redirects
stdout, but that does not affect the nohup cmd. BTW, what do you hope to
gain by \
"echo `date`"? Try:

nohup sh -c 'date;ls-l;date' >> logfile.txt &

Dan Mercer

LordSky

unread,
May 26, 2008, 8:46:37 AM5/26/08
to


Hi,
i think that you cannot suppress nohup.out file creation.
From the man page:

FILES
nohup.out The output file of the nohup execu-
tion if standard output is a termi-
nal and if the current directory is
writable.

$HOME/nohup.out The output file of the nohup execu-
tion if standard output is a termi-
nal and if the current directory is
writable

It indicates that every time nohup is called from terminal, it creates
the nohup.out file.
Regards


Darren Salt

unread,
May 26, 2008, 1:22:01 PM5/26/08
to
I demand that LordSky may or may not have written...

[snip]


> i think that you cannot suppress nohup.out file creation. From the man
> page:

> FILES
> nohup.out The output file of the nohup execu-
> tion if standard output is a termi-
> nal and if the current directory is
> writable.

"if standard output is a terminal".

So make it not a terminal. Redirect the output.

[snip]
--
| Darren Salt | linux or ds at | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
| + RIPA NOTICE: NO CONSENT GIVEN FOR INTERCEPTION OF MESSAGE TRANSMISSION

How much for the rocket launcher? ...does this include ammo?

0 new messages