Linux nohup command: The program continues to run in the background after exiting the terminal

Source: Internet
Author: User
Tags system log

Transferred from: http://tech.ccidnet.com/art/302/20070618/1115599_1.html

    • Simple and useful nohup command in Unix/linux, the normal process is placed in the background with the & symbol, and if you start the program's console logout, the process terminates.
    • To implement the daemon, one way is to program according to the rules of the daemon (this site an article introduced), more trouble; another approach is to still program with the normal method and then start the program with the Nohup command:

nohup< Program Name >&

After the console logout, the process continues to function as a daemon (although it is not a strict daemon).

    • Using the Nohup command, the original program's standard output is automatically redirected to the current directory of the Nohup.out file, played the role of log, the implementation of the full daemon function.

Ygwu @ April 18, 2005 10:03

For example:

    • How do I remotely start the WebLogic service?

Remotely control the server with Telnet, start the WebLogic service remotely, and then shut down the Telnet,weblogic service when it starts, because a process started with Telnet shuts down as the Telnet process shuts down. So we can use some UNIX commands to do it without shutting down.

Use the following command:

Nohup startweblogic.sh&

If you want to monitor standard output you can use:

Tail-f Nohup.out

    • When you run a program in the background, you can use the Jobs command to view the status of the background job. To use the FG command with parameters to switch background jobs of different numbers to run on the foreground when there are multiple daemons.
    • When the user initiates a process, the process is run in the foreground, using the standard input and output associated with the corresponding control terminal for input and output. Even if the input and output of the process is redirected and the process is placed in the background, the process is still related to the current terminal device. Because of this, at the end of the current logon session, the control terminal device will be disconnected from the login process, then the system to all the process associated with the terminal to send Sighup signal, notify the process line has been suspended, if the program does not take over the processing of this signal, then the default reaction is the process end. Therefore, the normal program does not really leave the login session and run the process, in order to make the system log on after the normal execution, only use the command nohup to start the corresponding program.
    • Using the command nohup can of course start such a program, but the Nohup startup program exits when the process finishes executing, while some common service processes typically run permanently in the background without outputting results to the screen. In Unix, these persistent daemon processes are called daemons (daemon). Daemons usually start automatically from the start of the system and stop when the system shuts down.
    • In the daemon, the most important one is the Super Daemon inetd, which takes over most of the network services, but does not handle each service on its own, but instead launches different service programs to deal with the client based on the connection request. INETD supports the type of network service defined in its settings file/etc/inet.conf. Each line in the inet.conf file corresponds to a port address, and when inetd accepts a connection request to the port, the appropriate process is initiated for processing. The advantage of using inetd is that the system does not have to start many daemons, thus saving system resources, while the inetd boot daemon can react slowly and not be suitable for dense-access service processes.
Related Article

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.