'CRON on Rpi simply will not run

I am using a Raspberry pi.

I need to turn on a LED whenever I'm connected to the net and turn off the LED if the connection ever fails. I want to use a cron job running once per minute to do this.

I wrote and compiled two programs in 'C' (ledon, ledoff) that handles the GPIO pin. Those programs work.

I am logged in as 'pi'.

I used crontab -e to write the following:

*/1 * * * * /home/pi/cron_scripts/nettest

I was informed by someone that the first asterisk must have '/1' in order to run properly at the once-per-minute rate that I want. There is no space to the left of the first '/1' and one space after the '1' and each '*' thereafter.

FOR TESTING ONLY, The contents of /home/pi/cron_scripts/nettest is -

#!/bin/bash

ping -c 1 -q 8.8.8.8

if [ "$?" -eq 0 ]; then

printf "%s\n\n" "SUCCESS\n"

else

printf "%s\n\n" "FAIL\n"

fi

exit 0

I used sudo chmod +x /home/pi/cron_scripts/nettest

to make the script executable. I will replace the printf lines with "ledon" and "ledoff" for the final version.

BUT IT WILL NOT RUN!



Solution 1:[1]

echo $(ping -c 1 -q 8.8.8.8)

etc.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PeterB