Page 1 of 1

Auto run c program in Rpi 3

Posted: Sat Apr 15, 2017 2:58 pm
by goutam
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.

Re: Auto run c program in Rpi 3

Posted: Sat Apr 15, 2017 3:22 pm
by allfox
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