LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-14-2011, 06:02 AM   #1
paolinux80
LQ Newbie
 
Registered: Apr 2011
Posts: 2

Rep: Reputation: 0
nohup outputs


Dear all,

I have been looking around in the forums and did some googling, but I could not find a solution to my problem.

I have to launch a code on a remote machine which has two types of output:
1) A lot of continuous messages in the stout (the display)
2) Every once in a while (let's say every hour) the code also writes a "solution" into files.

What I would like to do is to launch the code and keep it running even if I disconnect from the remote machine.

Well, the first solution I tried was a simple
$ nohup ./code &
which does the job but creates a file (nohup.out) which is way too large (talking about several tens or hundreds of Gb).

So I was not happy with this and I went for a
$ nohup ./code > /dev/null &
and I was very happy until I realised that the program is not writing the
"solutions" anymore. I guess is sending it to null.

By chance, I found that removing the nohup.out file while the program is running makes the deal: the code keeps running, the stout is redirected nowhere (I guess it cannot find the file so it forwards it to null), AND
I have my solutions file.

I was wondering if there is another, proper, correct way to do this, since I feel I am cheating a little.

A nice thing to do would be to actually write the nohup.out file, but limitating it in size: i.e. overwriting it when the file becomes too large.

I hope there is a solution! In any case, thanks for listening!
P.
 
Old 04-14-2011, 09:10 AM   #2
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
What is the "solutions" file?

Is it stdout or stderr? Does the program creeate a file? If so, where?
 
Old 04-14-2011, 11:10 AM   #3
kaiserkarl13
LQ Newbie
 
Registered: Jan 2010
Distribution: Fedora
Posts: 23

Rep: Reputation: 4
You have several options

I'm not exactly sure what you want, but here's what I typically do to run background jobs:
Code:
  $ ./code &
  $ disown
Using nohup should do more or less the same thing, except that nohup redirects stdout (output to the screen) to nohup.out. nohup will also redirect stdin from /dev/null, but that's what you want for background jobs anyway.

I have no idea without knowing the source of 'code' why it does write a file when you redirect stdout but doesn't if you don't. Is it a shell script or a compiled program? Either way, redirecting stdout to /dev/null shouldn't get rid of a file written during normal execution.
 
Old 04-17-2011, 03:57 PM   #4
paolinux80
LQ Newbie
 
Registered: Apr 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Hello all,

thank you for your replies.

The program I use is a g95-compiled program. The output files are created by the files itself, and (I guess) it is stout.

I will try the disown command and let you know if it solves the problem.

Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
nohup help rvaede Programming 7 03-09-2011 08:14 AM
nohup sycamorex Linux - General 4 01-08-2008 06:49 PM
problem with nohup command and nohup file size vbseeker Linux - General 1 09-17-2006 12:36 PM
Specify where nohup outputs to? chibi Linux - General 1 01-31-2006 03:15 AM
help on nohup vinayuh Linux - General 3 07-22-2005 01:24 PM


All times are GMT -5. The time now is 05:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration