Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7901993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:22:42+00:00 2026-06-03T09:22:42+00:00

I have a problem with the nohup command. When I run my job, I

  • 0

I have a problem with the nohup command.

When I run my job, I have a lot of data. The output nohup.out becomes too large and my process slows down. How can I run this command without getting nohup.out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:22:43+00:00Added an answer on June 3, 2026 at 9:22 am

    The nohup command only writes to nohup.out if the output would otherwise go to the terminal. If you have redirected the output of the command somewhere else – including /dev/null – that’s where it goes instead.

     nohup command >/dev/null 2>&1   # doesn't create nohup.out
    

    Note that the >/dev/null 2>&1 sequence can be abbreviated to just >&/dev/null in most (but not all) shells.

    If you’re using nohup, that probably means you want to run the command in the background by putting another & on the end of the whole thing:

     nohup command >/dev/null 2>&1 & # runs in background, still doesn't create nohup.out
    

    On Linux, running a job with nohup automatically closes its input as well. On other systems, notably BSD and macOS, that is not the case, so when running in the background, you might want to close input manually. While closing input has no effect on the creation or not of nohup.out, it avoids another problem: if a background process tries to read anything from a still-open standard input, it will pause, waiting for you to bring it back to the foreground and type something. So the extra-safe version looks like this:

    nohup command </dev/null >/dev/null 2>&1 & # completely detached from terminal 
    

    Note, however, that this does not prevent the command from accessing the terminal directly, nor does it remove it from your shell’s process group. If you want to do the latter, and you are running bash, ksh, or zsh, you can do so by running disown with no argument as the next command. That will mean the background process is no longer associated with a shell "job" and will not have any signals forwarded to it from the shell. (A disowned process gets no signals forwarded to it automatically by its parent shell – but without nohup, it will still receive a HUP signal sent via other means, such as a manual kill command. A nohup‘ed process ignores any and all HUP signals, no matter how they are sent.)

    Explanation:

    In Unixy systems, every source of input or target of output has a number associated with it called a "file descriptor", or "fd" for short. Every running program ("process") has its own set of these, and when a new process starts up it has three of them already open: "standard input", which is fd 0, is open for the process to read from, while "standard output" (fd 1) and "standard error" (fd 2) are open for it to write to. If you just run a command in a terminal window, then by default, anything you type goes to its standard input, while both its standard output and standard error get sent to that window.

    But you can ask the shell to change where any or all of those file descriptors point before launching the command; that’s what the redirection (<, <<, >, >>) and pipe (|) operators do.

    The pipe is the simplest of these… command1 | command2 arranges for the standard output of command1 to feed directly into the standard input of command2. This is a very handy arrangement that has led to a particular design pattern in UNIX tools (and explains the existence of standard error, which allows a program to send messages to the user even though its output is going into the next program in the pipeline). But you can only pipe standard output to standard input; you can’t send any other file descriptors to a pipe without some juggling.

    The redirection operators are friendlier in that they let you specify which file descriptor to redirect. So 0<infile reads standard input from the file named infile, while 2>>logfile appends standard error to the end of the file named logfile. If you don’t specify a number, then input redirection defaults to fd 0 (< is the same as 0<), while output redirection defaults to fd 1 (> is the same as 1>).

    Also, you can combine file descriptors together: 2>&1 means "send standard error wherever standard output is going". That means that you get a single stream of output that includes both standard out and standard error intermixed with no way to separate them anymore, but it also means that you can include standard error in a pipe.

    So the sequence >/dev/null 2>&1 means "send standard output to /dev/null" (which is a special device that just throws away whatever you write to it) "and then send standard error to wherever standard output is going" (which we just made sure was /dev/null). Basically, "throw away whatever this command writes to either file descriptor".

    When nohup detects that neither its standard error nor output is attached to a terminal, it doesn’t bother to create nohup.out, but assumes that the output is already redirected where the user wants it to go.

    The /dev/null device works for input, too; if you run a command with </dev/null, then any attempt by that command to read from standard input will instantly encounter end-of-file. Note that the merge syntax won’t have the same effect here; it only works to point a file descriptor to another one that’s open in the same direction (input or output). The shell will let you do >/dev/null <&1, but that winds up creating a process with an input file descriptor open on an output stream, so instead of just hitting end-of-file, any read attempt will trigger a fatal "invalid file descriptor" error.

    To answer Gwangmu Lee’s question: there’s no magic in nohup, since it’s not even a shell builtin (at least not in bash and zsh; it is in ksh, which allows you to use it to run other shell builtins). Any command can check to see if an open file descriptor points to the terminal or not, which is all it does to determine whether or not to write the nohup.out file.

    There aren’t any builtin shell commands that do redirection for you; that’s always under your explicit control. I suspect that’s because it would then be confusing if you added explicit redirections to a command that had implicit ones. But there’s nothing stopping you from doing redirects in your own scripts and functions. For example:

    run_detached() {
        nohup "$@" </dev/null >/dev/null 2>&1 &
        disown
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with fancybox. I want to write a function that will run
i have problem to correctly bind data to WPF Chart. When i'm setting ItemsSource
Have problem while getting data from Memcached on .NET MVC solution. I have this
I have problem with encoding data in Oracle database. I want to xor string
I have problem to update user data in cakephp. When I submit form I
I have problem with this method in NLog library: NLog.Targets.Wrappers.AsyncTargetWrapper.ProcessPendingEvents(object state) It consume too
I have problem with this code..I want to extract data from flat file and
I have problem with saving many to many relationship. When I run the code,
i have problem to pass data from view to controller , i have view
I have problem creating new instance of excel 2007 using VBA (from Access 2002).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.