Community
cancel
Showing results for 
Search instead for 
Did you mean: 
hdong5
Novice
1,119 Views

Auto run a program when power on

Jump to solution

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
101 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
102 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

hdong5
Novice
101 Views

Many thanks, Charlie.

Reply