Linux nohup and & background run, process view and termination, process information output, console information output

Source: Internet
Author: User

1.nohup

Purpose: To run the command without hanging off.

Syntax: Nohup Command [Arg ...] [&]

The output is appended to the Nohup.out file in the current directory, regardless of whether the output of the Nohup command is redirected to the terminal.

If the nohup.out file for 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, then the command specified by the commands parameter is not callable.

Exit Status: This command returns the following exit values: 126 You can find but cannot invoke the command specified by the command parameter.     The 127 nohup command has an error or cannot find the command specified by the commands parameter. Otherwise, the exit status of the Nohup command is the command parameter that specifies the exit state of the commands.

2.&

Purpose: Run in the background

Generally two one

Nohup Command &

eg

1 nohup /usr/local/node/bin/node /www/im/chat.js >> /usr/local/node/output.log 2>&1 &

Process number 7585

To view a running background process

(1) jobs-l

The jobs command only looks at the current terminal in effect, after shutting down the terminal, in another terminal jobs can not see the background running program, the use of PS (Process view command)

(2) Ps-ef

1 ps -aux|grep chat.js


x: Show All Programs, not the terminal to distinguish

Note:

With Ps-def | The grep lookup process is convenient, and the last line will always grep itself

The grep command can be ruled out with the GREP-V parameter

1 ps -aux|grep chat.js| grep -v grep

Then use awk to extract the process ID

1 ps -aux|grep chat.js| grep -v grep | awk ‘{print $2}‘

3. If a process does not come up, a port may be occupied

To view a process that uses a port

1 lsof -i:8090

1 netstat -ap|grep 8090

After viewing the process ID, use the netstat command to view the ports it occupies

1 netstat -nap|grep 7779

Kill the city with kill and start again.

4. Terminate the process running in the background

1 kill -9  进程号

Linux nohup and & background run, process view and termination, process information output, console information output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.