October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Use the nohup Command in Linux to Keep Processes Running

A practical Linux guide to nohup: protect commands from logout, redirect input and logs predictably, run them in the background, verify processes, troubleshoot failures, and understand when a service manager is required.
WorldLinux to Keep Processes Running Length10 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run a noninteractive command as nohup /path/to/command --option value </dev/null >run.log 2>&1 & to make it ignore the terminal hangup signal, detach its input and output from the terminal, and let the shell continue immediately. The final & is essential for background execution; nohup alone protects the command from SIGHUP but leaves it in the foreground.

What nohup actually protects

When an SSH connection, terminal emulator, or login session closes, the operating system can send a hangup signal, SIGHUP, to processes associated with that session. GNU nohup starts the requested command with hangup signals ignored. POSIX requires the utility to set SIGHUP to ignored when it is invoked. A process that inherits that setting can therefore continue after you log out.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The protection is narrow. nohup does not turn a command into a service, does not daemonize it, does not restart it after a crash, and does not provide health checks, startup-at-boot integration, resource limits, or log rotation. It is a lightweight wrapper for a job that should survive one logout, not a process supervisor.

Syntax and the role of &

The canonical form is:

nohup COMMAND [ARG]...

The shell still decides whether the wrapped command runs in the foreground or background. Without an ampersand, the command remains attached to the shell’s foreground job slot until it exits, even though it ignores SIGHUP. Add & after all redirections when you want your prompt back immediately.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
nohup /path/to/command --option value &

This command is protected from a hangup but may still read from the terminal and write output there. For an unattended job, make every stream explicit:

nohup /path/to/command --option value </dev/null >run.log 2>&1 &
  1. Use an absolute executable path or a command that you have verified is on the target user’s PATH.
  2. Choose a writable log directory before launching. For example, create a per-user directory with mkdir -p "$HOME/logs".
  3. Place </dev/null before the output redirections so the process has deliberate, noninteractive input.
  4. Use >run.log to create or truncate a log, or >>run.log to append to an existing one.
  5. Use 2>&1 after standard-output redirection so standard error goes to the same file description.
  6. Put & last. The shell then starts the job asynchronously and normally prints a job number and process ID.

Redirect all three standard streams

Standard input

An unattended process should not wait for keyboard input that can never arrive after logout. </dev/null immediately supplies end-of-file. If the program is meant to consume a file, replace it with an explicit input file such as <commands.txt. POSIX leaves some terminal-input details implementation-defined; an explicit redirection removes that ambiguity.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Standard output

>run.log writes standard output to a named file and truncates that file when the command starts. Use >>run.log when retaining earlier output matters. An absolute path such as /var/tmp/job.log avoids surprises if the launch directory changes, but the launching user must have permission to create or write the file.

Standard error and redirection order

2>&1 duplicates the current standard-output destination for file descriptor 2. Because shell redirections are processed from left to right, >run.log 2>&1 sends both streams to run.log, while 2>&1 >run.log can leave standard error pointing at the original destination. Keep the conventional order unless you intentionally want separate streams.

You can split the streams when that is more useful:

nohup /path/to/command </dev/null >stdout.log 2>stderr.log &

Neither nohup nor the shell limits log size. A verbose process can eventually fill the filesystem, so choose a location with sufficient space and arrange rotation or cleanup separately when the job is long-lived.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Where output goes when you omit a log path

GNU nohup changes terminal-connected output automatically. Its behavior is:

Stream or condition Result
Standard output is a terminal Append output to nohup.out in the current directory.
Current-directory nohup.out cannot be opened Try $HOME/nohup.out.
Neither output file can be opened Do not run the command.
Standard error is a terminal Normally redirect it to the same output descriptor used for standard output.
Standard input is a terminal Behavior has implementation-defined details; explicitly use </dev/null for unattended work.

The fallback explains why a file can appear in an unexpected working directory or in your home directory. Explicit paths are safer for scripts, cron-like tasks, game-server launches, and any job whose logs must be found later. Create the directory first and verify ownership and permissions:

mkdir -p "$HOME/logs"
test -w "$HOME/logs" || echo "log directory is not writable"
nohup /path/to/command </dev/null >"$HOME/logs/run.log" 2>&1 &

Practical launch patterns

Protected but foreground

nohup /opt/example/bin/task --once

Use this when you want to watch the command in the current shell and do not need another prompt. Logging follows the default rules unless you add redirections. Closing the terminal should not terminate the wrapped process, but you still have to wait for it in the foreground.

Background job with one log

nohup /opt/example/bin/task --once </dev/null >"$HOME/logs/task.log" 2>&1 &

This is the usual one-off pattern: no terminal input, one predictable log, and an asynchronous shell job.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Appending to a continuing log

nohup /opt/example/bin/task --watch </dev/null >>"$HOME/logs/task.log" 2>&1 &

Appending preserves earlier runs. If several instances write to the same file, their lines can interleave; choose separate log files when instance-specific records matter.

A generic long-running game process

nohup /opt/game/bin/server --world arena --port 27015 </dev/null >"$HOME/logs/arena-server.log" 2>&1 &

The wrapper only handles the Unix process and its streams. Saving game state, accepting players, handling signals, and recovering from application errors remain responsibilities of the server itself.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Verify that the job is really running

A prompt returning, or a shell message showing a background job, proves only that the launch was accepted. It does not prove that the application completed initialization or will stay healthy.

  1. Capture the process ID immediately if you need a direct handle: pid=$!. The value is the most recently started background process in that shell.
  2. Inspect the process with ps -p "$pid" -o pid,ppid,stat,etime,cmd. A missing row means that process has already exited.
  3. Search by command when the original shell is gone: pgrep -af 'example/bin/task'. Make the pattern specific enough to avoid matching unrelated jobs.
  4. Follow the log with tail -f "$HOME/logs/task.log". Look for the application’s own readiness or error messages.
  5. Check the process and log again after the expected startup interval. A process can launch successfully and then terminate because of a bad argument, missing file, permission error, or application-level failure.

These are ordinary Linux monitoring tools; nohup defines no monitoring interface of its own.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Interpret GNU nohup exit statuses

When the wrapper itself can start the command, GNU nohup returns the wrapped command’s exit status. Special values identify failures before normal command execution:

Status Meaning
125 nohup itself failed.
126 The command was found but could not be invoked.
127 The command could not be found.
Any other status The wrapped command returned that status.

With a final &, your interactive shell usually reports that it started a background job rather than waiting for the eventual application status. Use the log and process checks to determine whether the job remains alive; collect the application’s final status through its own logging or a supervising system when that distinction matters.

Common mistakes and precise fixes

Omitting the ampersand

Symptom: you cannot use the prompt until the command exits. Fix: add & after all arguments and redirections. The omission does not remove SIGHUP protection; it only keeps the job in the foreground.

Leaving output attached to a terminal

Symptom: output is missing, appears in an unexpected file, or the session remains noisy. Fix: redirect both output streams to a known path. Otherwise GNU nohup may create or append to nohup.out, first in the current directory and then under $HOME. Check available disk space for verbose jobs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Allowing terminal input

Symptom: the process pauses waiting for a prompt that nobody can answer. Fix: use </dev/null or provide a deliberate input file. Programs that fundamentally require an interactive terminal are a poor fit for nohup.

Writing to an unwritable log

Symptom: no log is created, or the command is not run when automatic output-file opening fails. Fix: create the directory first, test write access as the launching user, and use a path that user can open. Do not assume a service account can write to a system directory.

Assuming a successful launch means successful work

Symptom: the shell accepted the command but the process disappeared minutes later. Fix: inspect with ps or pgrep and read the log. Exit status 126 or 127 points to invocation or lookup problems; an application-specific nonzero status requires examining that application’s diagnostics.

Using a shell special builtin as the operand

GNU documentation says the command operand must not be a shell special built-in utility. Commands such as shell control constructs are interpreted by the shell rather than executed as ordinary external programs. Put the intended operations in an executable script and invoke that script instead:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
nohup /home/user/bin/nightly-task.sh </dev/null >"$HOME/logs/nightly.log" 2>&1 &

Expecting restart or boot persistence

Symptom: a crashed process stays down, or it is absent after a machine reboot. Fix: use a service or job-management system designed for restart policies and startup integration. nohup makes no such promise.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Shell and portability considerations

A shell may provide its own nohup function or builtin, which can take precedence over the external utility. Check the target environment with the shell’s command lookup facilities and read that environment’s manual page when behavior differs. If a script depends on GNU-specific behavior, run it on a system that provides GNU Coreutils and document that requirement.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

POSIX specifies the essential signal behavior and the nohup.out/$HOME/nohup.out fallback model, but permits implementation details around terminal standard input. Explicitly redirecting all three streams makes a script less dependent on those differences. Avoid relying on undocumented extensions when the same script must run across different Unix-like systems.

When nohup is the right tool—and when it is not

Requirement nohup Terminal multiplexer Service manager
Survive logout Yes, for a process that honors the inherited signal disposition. Yes, while the process remains in the detached session. Yes, as part of managed service execution.
Reconnect to an interactive terminal No. Yes; you can detach and later reattach to the session. Usually no interactive console; use service logs or a separate administration channel.
Automatic restart after failure No. No by itself. Yes, when configured with a restart policy.
Start at boot No. No by itself. Yes, when enabled for the system’s startup target.
Logging and rotation Basic redirection only; rotation is external. Captures a session but does not replace log management. Typically provides structured logging and rotation facilities, depending on the manager.
Resource controls and health checks None. None by itself. Available through the manager’s configuration.
Portability Widely available; exact defaults can vary. Depends on the multiplexer being installed. Depends on the operating system and manager.

Choose nohup for a one-off batch

Use it when you have a command that should finish independently of your SSH session, does not need a live console, and does not require automatic recovery. Explicit input and log redirection make the run reproducible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a terminal multiplexer for an interactive session

If you need to reconnect and continue typing commands or watching an interactive game console, a terminal multiplexer is a better match. It preserves the terminal session itself rather than merely ignoring SIGHUP.

Choose a service manager for an always-on process

For a server that must start with the machine, restart after failure, expose health state, enforce resource policy, or integrate with system logging, define it as a managed service. Wrapping it in nohup would hide those missing guarantees rather than supply them.

A reliable checklist before logging out

  • Confirm the executable path and arguments independently in the foreground.
  • Decide whether the process is truly noninteractive.
  • Create and permission-check the log directory.
  • Redirect standard input, output, and error explicitly.
  • Add & only after the complete command and redirections.
  • Record the displayed process ID or assign pid=$!.
  • Use ps, pgrep, and tail -f to verify startup.
  • Check that the log location has enough capacity for the expected output.
  • Decide whether the job actually needs restart, boot startup, interactive reconnection, or resource controls; if so, use a more capable manager.

Troubleshooting by symptom

Symptom Likely cause Action
The command blocks your prompt. The final & is missing. Stop it if appropriate and relaunch with &.
No named log exists. Output was left to automatic handling, or the path is unwritable. Look for nohup.out in the current directory and $HOME; then relaunch with a tested explicit path.
The process waits indefinitely. It is reading terminal input. Supply an input file or relaunch with </dev/null if it is noninteractive.
The process exits immediately with 126. The executable was found but cannot be invoked. Check execute permission, interpreter availability, and executable format.
The process exits immediately with 127. The command cannot be found. Use an absolute path or correct the launching user’s PATH.
The process disappears later. The application failed after startup; nohup does not restart it. Read the combined log and use a supervisor if automatic recovery is required.
The filesystem fills up. Unbounded output is accumulating. Reduce verbosity, choose an appropriate log destination, and arrange external rotation or cleanup.

Bottom line

nohup is the correct small tool for keeping a noninteractive Linux command alive across logout: ignore SIGHUP, redirect every standard stream, and add & when asynchronous execution is required. Verify the process and its log after launch. As soon as you need reconnection, automatic restart, boot integration, health checks, resource controls, or managed logs, move from a wrapper to a terminal multiplexer or service manager suited to that requirement.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.