Raspberry PI writes the Python script to the service and sets the boot up

Source: Internet
Author: User
Tags syslog python script

1#!/bin/Bash2#/etc/init.d/service_name3 4 # # # BEGIN INIT INFO5 # Provides:provider6# required-Start: $remote _fs $syslog7# required-Stop: $remote _fs $syslog8# Default-start:2 3 4 59# Default-stop:0 1 6Ten# short-description:example Initscript One # Description:this Service is a test A # # # END INIT INFO -  -  the  Case " $" inch  - start) -         Echo "starting service_name" -cd/home/Pi +         suPi-c"python/home/pi/pythoncode/test.py" -         ;; + stop) A         Echo "stopping service_name" at         Killallservice_name -         ;; -*) -         Echo "Usage:/etc/init.d/service_name start|stop" -Exit1 -         ;; in Esac -Exit0
View Code

First, in console input: sudo nano/etc/init.d/service_name, copy the above code into the file. In the above code, "Service_Name" is your own name for this service, and BEGIN INIT INFO changes as needed without affecting the program.

Save the file, and then enter

1 sudo chmod +x/etc/init.d/service_name

Where Service_Name is your own name.

Input

1 sudo update-rc.d/etc/init.d/service_name defaults

Can.

Reference: http://raspberrywebserver.com/serveradmin/run-a-script-on-start-up.html

Raspberry PI writes the Python script to the service and sets the boot up

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.