How to start python program at boot on Arch Linux ARM?

8,118

Solution 1

A systemd service file would look like this: (required parts in bold)

[Unit]
Description=Foo service

[Service]
ExecStart=/path/to/script.py
# "Type=forking" or "Type=oneshot" may also be needed

[Install]
WantedBy=multi-user.target

You can also make it start as a specified user, restart on crash, and so on. See systemd.exec(5) and systemd.service(5) for all the available options.

Put your service file in /etc/systemd/system/name.service.

To make it start on boot, use systemctl enable name.service.

Solution 2

You shouldn't have to. You can add it to crontab as a user. run crontab -e to edit the crontab, and add the line @reboot /path/to/command.py In some cases you may need to explictly call python or run a bash script that runs the python file. Nonetheless, crontab's probably the easiest way to do it.

Share:
8,118

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I am running Arch Linux ARM on my Raspberry Pi, and I need to start a python (which should keep running until it either crashes or the machine loses power) program at boot with no input at all from the user after boot.

    I'm a little new to Arch, so I don't really know how to write services and all that.

  • Gotschi
    Gotschi over 10 years
    This killed my Raspberry Pi login (ssh) for everyone else having this Problem, issue: ssh user@host "rm /etc/profile.d/myshellscript.sh"