Linux nohup command principle and example analysis

Linux nohup command principle and example analysis

nohup Command

When using Unix/Linux, we usually want a program to run in the background, so we often use & at the end of the program to make the program run automatically. For example, we want to run mysql in the background: /usr/local/mysql/bin/mysqld_safe –user=mysql &. But many programs are not like mysqld, so we need the nohup command

Process and job management

The nohup command can run the program in a way that ignores the hang-up signal, and the output information of the program being run will not be displayed to the terminal.

Regardless of whether you redirect the output of the nohup command to a terminal, the output is appended to the nohup.out file in the current directory. If the nohup.out file in the current directory is not writable, the output is redirected to the $HOME/nohup.out file. If no file can be created or opened for appending, the command specified by the command parameter cannot be invoked. If standard error is a terminal, then all output of the specified command written to standard error is redirected to the same file descriptor as standard output.

grammar

nohup(option)(parameter)

Options

--help: online help;

--version: Display version information.

parameter

Program and options: The program to run and the options.

Examples

one.

Run the spring boot jar package. When the current terminal is closed, the Spring Boot project still runs in the background.

nohup java -jar springboot.jar &

two.

Use the nohup command to submit a job. If you use the nohup command to submit a job, all output of the job is redirected to a file named nohup.out by default, unless an output file is specified otherwise:

nohup command > myout.file 2>&1 &

In the above example, the output is redirected to the file myout.file

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Use of Linux passwd command
  • Detailed explanation of the use of Linux time command
  • Use of Linux ln command
  • Detailed explanation of commands to read and write remote files using Vim in Linux system
  • Detailed explanation of the usage of grep command in Linux
  • A complete list of commonly used Linux commands (recommended collection)
  • Solve the problem that the commonly used Linux command "ll" is invalid or the command is not found
  • Baota Linux panel command list
  • Extract specific file paths in folders based on Linux commands
  • Linux file management command example analysis [display, view, statistics, etc.]
  • Use of Linux usermod command

<<:  vue-pdf realizes online file preview

>>:  Tutorial on installing the latest MySQL 8.0.18 using a compressed package on Win10 64-bit (with pictures and text)

Recommend

Vue implements login jump

This article example shares the specific code of ...

How to show or hide common icons on the desktop in Windows Server 2012

Windows Server 2012 and Windows Server 2008 diffe...

Detailed explanation of mysql integrity constraints example

This article describes the MySQL integrity constr...

Install and deploy java8 and mysql under centos7

Generally, learning Java and deploying projects a...

How does the MySQL database implement the XA specification?

MySQL consistency log What happens to uncommitted...

10 ways to view compressed file contents in Linux (summary)

Generally speaking, when we view the contents of ...

Introduction to using the MySQL mysqladmin client

Table of contents 1. Check the status of the serv...

How to implement mask layer in HTML How to use mask layer in HTML

Using mask layers in web pages can prevent repeat...

Logrotate implements Catalina.out log rotation every two hours

1. Introduction to Logrotate tool Logrotate is a ...

Using nginx + fastcgi to implement image recognition server

background A specific device is used to perform i...

Solve the problem of black screen when starting VMware virtual machine

# Adjust VMware hard disk boot priority Step 1: E...

A brief discussion on how to write beautiful conditional expressions in JS

Table of contents Multiple conditional statements...