Code: Select all
@reboot /my_path/my_exec_file_or_script opt_parms_here
Hi, I have tried so many times.still could not make it. I am using a laser scanner with Raspberry Pi2. It could work perfectly until I set to auto run at startup. It would hang there.lmarmisa wrote: ↑Tue Jul 25, 2017 3:49 pmIf you wish to run automatically CLI commands or scripts (bash, python, etc) at startup, crontab should work fine.
I do not understand your comment related to compile and make.
When you compile a program, you generate an executable program which is ready to run. You will not need to recompile it again except if you have modified its source code.
So, you have no need to recompile a program after a reboot or something like that. Simply you have to call the executable file previously generated. If you use crontab -e, add a line like this:Code: Select all
@reboot /my_path/my_exec_file_or_script opt_parms_here
I ran it normally by pi@raspberrypi: sudo ./get_distance
When a program is run from rc.local it runs as root, so sudo is not required.
Code: Select all
if [ $(tty) == /dev/tty1 ]; then
sudo ./get_distance
fi