Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.