Linux Boot Execution python script

Source: Internet
Author: User
Tags python script

First, using Init
1, the system has a corresponding Python interpreter, and in the script header declaration, for example:#!/usr/bin/python
+x somescript.py
Start this command format to launch the program
4. Place the script under the/etc/rc.d/init.d/path
--add somescript.py Add Service
3 somescript.py on Boot the service on Init 3 or 5 level

When running Chkconfig, the program will error and need to include in the file:

1 # chkconfig:- 2 # Description:xxxx is a service

It is recommended that you set the init level to 3, because setting it to 5 o'clock runs two scripts.

Later found, Level 3 also has the same problem.

Second, the use of SYSTEMD

Writing Device.service Scripts

1 [Unit]2description=xxxx3After=Network.service4 ?5 [Service]6Type= Simple7User=Root8group=Root9Workingdiretory=/var/www/html/appTenexecstart=/usr/bin/python app.py One ? A [Install] -Wantedby=multi-user.target

Copy the script to/etc/systemd/system/and give the app.py script Execute permissions:

1 chmod +x app.py

Start the service:

1 systemctl start App.service

View service Status:

1 systemctl status App.service

Stop service:

1 systemctl stop App.service

Done!!!

Most Linux platforms now offer SYSTEMD, and individuals recommend using SYSTEMD. SYSTEMD Tutorial Please go to Nanyi tutorial.

Linux Boot Execution python script

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.