Running the Python scripting service in the background

Source: Internet
Author: User
Tags python script

In the server, the program is running in the background, when writing a Python script, you need:

If you want Python robot.py & is not possible, once the user log out, the script will automatically exit. With at, Cron can be implemented, but I found a command.

Nohup, can ignore log out of the signal, now as long as

Nohup python robot.py &
Just fine. If you want to record the print in Python, you can

Nohup python robot.py & >/log/log1.log

View Python--pid running in the background

Command:ps-ef |grep python

Find the execution file and its path in Linux based on the PID value of the process

Lsof-p PID

1.3 FG Command (foreground)

This command will transfer the process running in the background to the foreground to run. Specific usage: FG%n. Here n is the jobnumber that Jobs sees. Such as:

The following commands can be used to manipulate process tasks:
PS Lists the processes that are running in the system
Kill sends a signal to one or more processes (often used to kill a process)
Jobs lists the processes that belong to the current user
BG moves the process to the background (Background)
FG moves the process to the foreground (Foreground)

Running the Python scripting service in the background

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.