Learn a Linux command every day (99): nohup

Time:2021-9-17

Command introduction

The nohup command is used to run a process in the background (without hanging up).

Command syntax

nohup Command [ Arg … ] [ & ]

Option description

--Help # print help and exit
--Version # print version information and exit

Application examples

Background operation

[[email protected] ~]# nohup java -server -Xms128M -Xmx512M -XX:MetaspaceSize=128M -jar test.jar $1 $2 $3 &

Execute the test.sh script and redirect the input to the test.log file

[[email protected] ~]# nohup /scripts/test.sh > test.log 2>&1 &

2> & 1 explanation
#Redirect standard error 2 to standard output & 1, which is then redirected into the test.log file.
0 – stdin (standard input)
1 – stdout (standard output)
2 – stderr (standard error output)

Learn a Linux command every day (99): nohup