I have a simple code that prints “Hello World” out serial. When I compile it with the commands:
gcc main.c -o main
gcc main.c -o -std=gnu99 main
they both compile and create an executable. When I run the executable, it works every time. However, when I put this in crontab, it works only sometimes. I also notice when it doesnt work and I log in root again, running the executable does not work anymore.
Why would the executable be deleted? Can crontab change the contents of the executable?
When the executable is not successful, the journalctl output stops with the following line:
Jan 01 00:00:07 beaglebone kernel: gpiochip_add: registered GPIOs 0 to 31 on device: gpio
when the executable is successful, this line follows:
Jan 01 00:00:07 beaglebone kernel: OMAP GPIO hardware version 0.1
Why would the beaglebone black stop after the gpiochip_add?
I am getting the same results using crontab and the service method below. For some reason the executable file is being cleared most of the time after being called at boot up.
Compile the required code.
Create a bash script that will launch the code at boot/ startup
Type nano <scriptname.sh>
Save and grant execute permission
chmod u+x /usr/bin/.sh
3. Create the service
4. Edit the above file as necessary to invoke the different functionalities like network. Enable these only if the code needs that particular service. Disable unwanted ones to decrease boot time.
5. Create a symbolic link to let the device know the location of the service.
ln /lib/systemd/.service .service
- Make systemd reload the configuration file, start the service immediately (helps to see if the service is functioning properly) and enable the unit files specified in the command line.
systemctl start .service
systemctl enable .service