Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer

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|improve this answer

I have recently installed arch linux (commandline only, no X) on a pokini. My solution to starting a shell script, was to put it in /etc/profile.d/myshellscript.sh

share|improve this answer
    
This killed my Raspberry Pi login (ssh) for everyone else having this Problem, issue: ssh user@host "rm /etc/profile.d/myshellscript.sh" – Gotschi Aug 6 '13 at 21:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .