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

Java+Tomcat environment deployment and installation process diagram

Next, I will install Java+Tomcat on Centos7. Ther...

VUE+Canvas realizes the whole process of a simple Gobang game

Preface In terms of layout, Gobang is much simple...

Simple web design concept color matching

(I) Basic concepts of web page color matching (1) ...

Windows platform configuration 5.7 version + MySQL database service

Includes the process of initializing the root use...

A simple way to call desktop exe programs on a web page

This article mainly introduces how to call desktop...

Native JS to implement drag position preview

This article shares with you a small Demo that ad...

Analysis of MySQL lock mechanism and usage

This article uses examples to illustrate the MySQ...

Install and configure ssh in CentOS7

1. Install openssh-server yum install -y openssl ...

In-depth understanding of this in JavaScript

In-depth understanding of this in Js JavaScript s...

MySQL fuzzy query statement collection

SQL fuzzy query statement The general fuzzy state...

CSS3 mouse hover transition zoom effect

The following is a picture mouse hover zoom effec...