I have a Python script on my Raspberry Pi running on Arch Linux ARM. To start the script, I use this command:

sudo python2 screen/screen.py

and it works perfectly. Now, my question is, how I can run this script automatically on start-up?

有帮助吗?

解决方案

In the folder /etc/systemd/system/ make a file named screen.service

The contents of that file might look like this (change for your use):


[Unit]

Description=Launches screen with my config

After=network.target

[Service]

Type=simple

ExecStart=command_you_want_to_run

RemainAfterExit=true

[Install]

WantedBy=multi-user.target

When you're finished run systemctl enable screen.service

The WantedBy line tells systemd where to make the symlink.

To learn more about the options for service unit files check out the docs: man systemd.service

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top