Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9881 Discussions

Auto run a program when power on

hdong5
Novice
1,217 Views

Hi, I put a python program on root/ . I am wondering how could I let edison to run the program when it power on?

 

Many thanks

Hao

1 Solution
Carlos_M_Intel
Employee
199 Views

Hi Hao,

You can create a script to run at boot. Take a look at the following threads:

I wrote an example on where I had a blink.py in /home/root

root@edison:~# vi script.sh

# !/bin/sh

/usr/bin/python /home/root/blink.py

In order to make it an executable

root@edison:~# chmod +x script.sh

Then, you must create the service

root@edison:~# vi /lib/systemd/system/blinkpy.service

# !/bin/sh

[Unit]

Description=Blink with Python

After=network.target

[Service]

ExecStart=/home/root/script.sh

Environment="HOME=/home/root"

WorkingDirectory=/home/root/

[Install]

WantedBy=multi-user.target

Finally, you need to start and enable the service

root@edison:~# systemctl daemon-reload

root@edison:~# systemctl start blinkpy.service

root@edison:~# systemctl enable blinkpy.service

Regards,

Charlie

View solution in original post

2 Replies
Carlos_M_Intel
Employee
200 Views

Hi Hao,

You can create a script to run at boot. Take a look at the following threads:

I wrote an example on where I had a blink.py in /home/root

root@edison:~# vi script.sh

# !/bin/sh

/usr/bin/python /home/root/blink.py

In order to make it an executable

root@edison:~# chmod +x script.sh

Then, you must create the service

root@edison:~# vi /lib/systemd/system/blinkpy.service

# !/bin/sh

[Unit]

Description=Blink with Python

After=network.target

[Service]

ExecStart=/home/root/script.sh

Environment="HOME=/home/root"

WorkingDirectory=/home/root/

[Install]

WantedBy=multi-user.target

Finally, you need to start and enable the service

root@edison:~# systemctl daemon-reload

root@edison:~# systemctl start blinkpy.service

root@edison:~# systemctl enable blinkpy.service

Regards,

Charlie

hdong5
Novice
199 Views
Reply