goutam
Posts: 3
Joined: Mon Apr 10, 2017 1:18 pm

Auto run c program in Rpi 3

Sat Apr 15, 2017 2:58 pm

I have a c program, I compiled it and created an object file. I need that to run automatically when I boot up. can anyone please help me in detail steps. I tried few things which I found in internet but none of them worked fine.

thank you.

User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

Re: Auto run c program in Rpi 3

Sat Apr 15, 2017 3:22 pm

If you just want it to run, nor more requirement, then you could edit /etc/crontab, add some line like

Code: Select all

@reboot root    /bin/echo none > /sys/class/leds/led1/trigger
This would execute "/bin/echo none > /sys/class/leds/led1/trigger" as root when reboot.

If you want something like "run my program after networking is ready", then you might need write a real systemd service unit.
Or wait 60 seconds or so before execute your program:

Code: Select all

@reboot root    sleep 60;/bin/echo none > /sys/class/leds/led1/trigger

Return to “General discussion”