Linux shell pid

Source: Internet
Author: User

Assume that a rails program is started:
Ruby script/Server
This is usually the case:
Nohup Ruby script/Server &
The error output stream is also directed to the normal output stream:
Nohup Ruby script/Server & 2> 1 &

To record the PID:
Nohup Ruby script/Server & 2> 1 & Echo $! > TMP/PID &

After repeated debugging, the above statement seems inappropriate. The total number of PID values written down is 1 larger than the actual PID, so it is changed:
Nohup Ruby script/Server & Echo $! > TMP/PID & 2> 1 &
That's all.

The above problems were confirmed by colleagues in the C ++ group in the company, but they agreed that adding 2> 1 will not change the process number, which is inconsistent with my actual test.

Kill $ (cat tmp/PID)

The above nohup will be output to the nohup. Out file in the current directory. You can also change it:
Nohup Ruby script/Server>/dev/null & Echo $! > TMP/PID & 2> 1 &

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.