亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
Table of Contents
What Is Nohup?
Nohup.out
How Is Nohup Different Than a Daemon?
Running a Process With Nohup
Running Multiple Commands With Nohup
Frequently Asked Questions
My application is still closing when I close the terminal. What should I do?
What about commands that require root password and other input?
Why is nohup redirecting stderr to stdout?
Home Computer Tutorials Computer Knowledge What Is Nohup and How Do You Use It? - Make Tech Easier

What Is Nohup and How Do You Use It? - Make Tech Easier

Jul 28, 2025 am 12:23 AM

There are many available commands on Linux systems. Some you’ll use multiple times a day, while others are generally reserved for special uses. nohup is one such command. You won’t use it every day, but you’ll be grateful that it’s around when you need it. Here we show you what nohup is and how to use it.

Table of Contents

  • What Is Nohup?
  • Nohup.out
  • How Is Nohup Different Than a Daemon?
  • Running a Process With Nohup
  • Running Multiple Commands With Nohup
  • Frequently Asked Questions

What Is Nohup?

What Is Nohup and How Do You Use It? - Make Tech Easier

nohup is short for “No Hangups.” It’s not a command that you run by itself. nohup is a supplemental command that tells the Linux system not to stop a command once it has started. It’ll keep running until it’s done, even if the user that started it logs out. It serves a somewhat similar purpose to tmux or screen, allowing you to start a process and not worry about whether it’ll finish if you log out or get disconnected from your server.

The syntax for nohup is simple and looks something like this:

nohup sh your-script.sh &

Notice the & at the end of the command. That moves the command to the background, returning you to the prompt on the terminal you’re working on. Many times the command will still remain attached to the terminal, so you’ll terminate it the moment you close the open window and precede the command with nohup.

nohup works with just about any command that you run in the terminal. It can be run with custom scripts as well as standard system commands and command line utilities. Use it to start a security auditing script on a remote server so that you can disconnect and walk away or to run updates in the background and not have them stop for anything.

Tip: check out other ways to run bash commands in the background.

Nohup.out

Because nohup can keep running independent of the user that started it, the command needs somewhere to output any messages or errors. As there isn’t a terminal to associate with it, nohup logs everything to a “nohup.out” output file

By default, that file is located in whichever directory you started the command. “nohup.out” is somewhat unique, as it contains both the standard output and the error output. nohup redirects both to the same file by default.

What Is Nohup and How Do You Use It? - Make Tech Easier

You don’t necessarily need to use “nohup.out,” though – it’s just the default. You can specify a custom output when you run nohup and place it in a custom location.

nohup sh your-script.sh > /path/to/custom.out &

The custom output contains the same data as the standard “nohup.out” file and is nice for the security audit script mentioned above. You could name it “audit-script-output.txt” in some kind of mounted remote folder and view that server’s security posture from the comfort of your own laptop rather than looking through cat outputs all day.

Even for normal everyday users, specifying a custom output file could be useful, as it would allow you to have a clear distinction between outputs. If you use this command multiple times from your default (home) folder without specifying an output file, “nohup.out” will just append itself with all outputs, creating a bit of a mess. If you want to read command output in an organized manner, specifying custom file names for each output gives you a means to do that in your own way!

How Is Nohup Different Than a Daemon?

By this point, you’re probably wondering what sets nohup apart from a daemonized process. After all, they both do seem to serve relatively the same purpose but don’t really.

Daemons run continuously in the background. They’re best reserved for processes that you don’t want to ever exit, like servers. They require more work to program, too, so they’re not best for simple one-off scripts.

nohup is more of a single-use command. Think of it as a script that will take a long time to run but will still ultimately finish. Maybe there’s a long and complicated task that you run every now and then that takes hours to complete. You don’t want to leave a terminal open or a user logged in, so use nohup to keep it running in the background and put all of the output into whatever file you choose, whether the default “nohup.out” or a location of your choice.

Running a Process With Nohup

To run a process with nohup, put it before any command you run. This includes all normal programs you would run, such as Discord, Steam, your browser, a text editor, or any other application you can think of.

Remember, you must detach your process from the active prompt so that you can close your terminal without suddenly losing the process.

For example, to open Kate (my text editor) on my system and detach it from the terminal while keeping a log with “kate.log,” I would type this:

nohup kate > kate.log &

After closing the terminal, Kate is still running.

What Is Nohup and How Do You Use It? - Make Tech Easier

If there were a problem starting the application, I could simply pull up “kate.log” and figure out what’s wrong directly from the terminal with:

cat kate.log

What Is Nohup and How Do You Use It? - Make Tech Easier

This process is useful to determine whether there’s an issue with an application that refuses to start or behaves erratically. When you typically start a program like your browser, its error signals are often ignored. Starting them in the terminal with nohup and passing the output onto a logfile helps paint a clearer picture of what could be causing problems.

Running Multiple Commands With Nohup

Since you can pass any command through nohup, you can also pass a command sequence. To do this correctly, you’ll have to invoke a shell first and pass the commands along as a string, as most terminal emulators interpret every command after the first as not being preceded by nohup.

Every modern Linux distro has bash installed, so we are ignoring other custom shells and using that one for this example:

nohup bash -c 'command1 && command2' &

In this command, we invoked bash to execute a command and chained them with a double-ampersand (&&). We’re telling nohup to “Run bash with the -c (execute) flag and pass this string surrounded by single quotes to it.” Then we tell the terminal to free up the prompt while that entire sequence runs in the background.

Frequently Asked Questions

My application is still closing when I close the terminal. What should I do?

Double-check that you’ve typed the ampersand (&) after your command. If it’s still closing when you close the terminal, try running it again. Then, in a new line, type: disown

This removes the running process completely from the terminal’s job list. In some cases, a process you start with nohup and the ampersand will continue to request input and listen for signals from the terminal. When the terminal closes, if the application is still in the job list, it will also send signals to it. The application will also close if it considers the terminal’s signal its cue to close.

Disowning it ensures that this doesn’t happen.

What about commands that require root password and other input?

We wouldn’t recommend running a command that requires terminal input or root access through nohup. If you absolutely have to, read the manual for the command you want to run and see whether there’s an option to skip confirmations. For example,. to just run the package manager in Arch Linux without confirmations, use its --noconfirm flag.

It’sna murky and dangerous territory for root access. If you insist on running a command through nohup as root, do so after entering the root shell by typing su in your terminal and going through with it. You’ll often find that applications that want your root password won’t react well to this.

Why is nohup redirecting stderr to stdout?

When you run a command through nohup, you’ll get an output that reads: nohup: ignoring input and redirecting stderr to stdout

What this means is that you will no longer be able to send terminal input to the command you just ran, and all the data that would normally stream through your terminal will be redirected to one single stream (stdout), then output into a file (by default, “nohup.out”).

Screenshots for “What Is Nohup?” and “Nohup.out” by John Perkins, and those for “Running a Process With Nohup” by Miguel Leiva-Gomez.

The above is the detailed content of What Is Nohup and How Do You Use It? - Make Tech Easier. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
Google Translate Picture | Translate Text in Images - MiniTool Google Translate Picture | Translate Text in Images - MiniTool Jul 12, 2025 am 12:57 AM

This Google translate picture guide shows you how to translate text from an image. If you are looking for more computer tips and solutions, you can visit php.cn Software official website where you can also find some useful computer tools like php.cn

How to Install Device Drivers Manually on Windows 11/10? - MiniTool How to Install Device Drivers Manually on Windows 11/10? - MiniTool Jul 06, 2025 am 12:15 AM

If your Windows 11/10 computer doesn’t automatically the latest versions of device drivers, you will need to manually install them. In this post, php.cn Software will show you 3 different methods to manually install drivers on your device.

How to Amplify/Boost/Increase Microphone Volume Windows 11? - MiniTool How to Amplify/Boost/Increase Microphone Volume Windows 11? - MiniTool Jul 06, 2025 am 12:27 AM

This post delivered by php.cn official web page introduces three methods to improve microphone volume and boost its performance, in Control Panel, via Settings, and by Device Manager. Read the below content to view details.

How to Open and Run dxdiag.exe on Windows 10/11 How to Open and Run dxdiag.exe on Windows 10/11 Jul 06, 2025 am 12:23 AM

This post includes answers for what is dxdiag, how to run dxdiag in Windows 10/11, DirectX Diagnostic Tool’s main functions, and how to update dxdiag.exe driver. php.cn Software also provides many other computer tips and solutions for users. You can

what is an operating system what is an operating system Jul 11, 2025 am 03:16 AM

The operating system is the basic software for managing hardware resources, running programs, and providing user interaction interfaces. It coordinates the relationship between hardware and software and is responsible for memory allocation, device scheduling, file management and multitasking. Common systems include Windows (suitable for office and gaming), macOS (Apple devices, suitable for creative work), Linux (open source, suitable for developers), and Android/iOS (mobile device system). The choice of ordinary users depends on the usage scenario, such as software compatibility, security and customization requirements. How to view system information: Use winver command for Windows, click on the machine for macOS, use terminal commands for Linux, and find the phone in settings. The operating system is the underlying tool for daily use,

Best Ways to Fix Windows 11/10 Control Panel Not Opening! Best Ways to Fix Windows 11/10 Control Panel Not Opening! Jul 08, 2025 am 12:01 AM

Have you ever wanted to adjust computer settings to fix some issues but suffered from Control Panel not opening? There is nothing more frustrating than this app not turning on, stopping you from viewing and changing system settings. In this post, mul

What Is Dell Digital Locker? How to Log in and Use It on Dell PC? - MiniTool What Is Dell Digital Locker? How to Log in and Use It on Dell PC? - MiniTool Jul 07, 2025 am 12:28 AM

What is Dell Digital Locker? How to log into Dell Digital Locker? This post from php.cn provides answers. Besides, you can know how to use your Dell Digital Locker to find software products included with your Dell computer.

How to Open Windows 11 Computer Management Console in 7 Ways? - MiniTool How to Open Windows 11 Computer Management Console in 7 Ways? - MiniTool Jul 09, 2025 am 12:18 AM

This essay summarized by php.cn Software mainly teaches you how to open Windows 11 Computer Management with Windows Search, Quick Link menu, Run dialog, command prompt, PowerShell, File Explorer, Control Panel, as well as a desktop shortcut.

See all articles