You are not logged in.

#1 2013-12-25 21:58:29

Flashback
Member
Registered: 2013-12-25
Posts: 1

Run Python script at start-up

Hello,

First of all I would like to let you know that I am a Newbie with Linux and Python. I have a Python script on my Raspberry Pi running on Arch Linux. To start the script, I use this command:

sudo pythong2 screen/screen.py

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

Offline

#2 2013-12-25 22:17:12

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Run Python script at start-up

Arch Linux doesn't run on ARM: https://bbs.archlinux.org/viewtopic.php?id=153431


https://wiki.archlinux.org/index.php/Autostarting
You have to post what exactly do you mean by 'start-up': booting to console, straight to X - if so, what WM / DE etc.

Offline

#3 2013-12-25 22:38:16

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Run Python script at start-up

Not a Programming issue, moving to NC...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2013-12-26 02:57:31

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,097

Re: Run Python script at start-up

https://wiki.archlinux.org/index.php/Sy … vice_files

Asuming your script is something that should be run at startup, and not at login by your user.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#5 2013-12-26 09:04:39

Alber
Member
From: Spain - España
Registered: 2011-11-11
Posts: 227

Re: Run Python script at start-up

Hello

I have a Python program running in an Raspberry. (As Mr.Elending, Karol points) It starts at startup, not at login, and it keeps running.
I'll tell what I've done, but surely is very interesting read more about it.

You must use a system's de service unit. Locate it in /etc/systemd/system.
Example:
/etc/systemd/system/ana-server.service

[Unit]
Description=Servidor TCP/IP-Serie para la comunicacion con los sensores del Arduino
After=syslog.target network.target
[Service]
ExecStart=/usr/share/analog/analogArduinoServer.py
Restart=on-abort
[Install]
WantedBy=multi-user.target

Try first with

systemctl daemon-reload
systemctl start ana-server.service

If it works, do the next to it start at boot:

systemctl enable ana-server.service

About the Python script:
In my case I've change its permissions to executable.
Too, I think, you can put in parameter ExecStart=python /usr/share/analog/analogArduinoServer.py
You can move your Python script to another place.

Last edited by Alber (2014-01-05 17:58:14)


Because not all of us are native English speakers, try no to use slang or abbreviations, thank you.

Offline

Board footer

Powered by FluxBB