I read plenty of Q&A about cron but I was not able to understand an anomaly which I am facing. I have a Raspberry Pi running 3 cronjobs:
* * * * * /home/pi/heartbeatgenerator.sh 2>&1
*/5 * * * * /home/pi/extase2influx/extase2influx.sh 2>&1
*/5 * * * * /home/pi/ows2influx/ows2influx.sh 2>&1
The first one is a simple script which write every minute 0 or 1 alternatively to a database (InfluxDB) via a curl call. The idea is to check if the RPi has a regular connection to the DB and function properly. It looks like this:
value=$(($( date +"%M")%2))
curl -i -XPOST "https://[REDACTED].influxcloud.net:8086/write?db=[REDACTED]&u=[REDACTED]&p=[REDACTED]&precision=s" \
--data "heartbeat $HOSTNAME=$value"
The second script is query some sensors and posting the values to the same DB. The third script is bascially the same of the second one, but the first line has a 'sleep 10s' command (to avoid a spike in CPU/network usage).
Now, everything is working nicely EXCEPT that the first script (the heartbeat) fails regularly every hour at minute 08 and 09. It fails meaning no data are posted into the DB. This is a piece of the DB dump:
1/7/2019 1:05:06.000000000 PM,1
1/7/2019 1:06:01.000000000 PM,0
1/7/2019 1:07:01.000000000 PM,1
1/7/2019 1:10:01.000000000 PM,0
1/7/2019 1:11:01.000000000 PM,1
1/7/2019 1:12:02.000000000 PM,0
This is how looks like visually
Here is a piece of the logfile:
Jan 7 13:05:01 RPi CRON[6346]: (pi) CMD (/home/pi/ows2influx/ows2influx.sh 2>&1)
Jan 7 13:05:01 RPi CRON[6347]: (pi) CMD (/home/pi/extase2influx/extase2influx.sh 2>&1)
Jan 7 13:05:01 RPi CRON[6348]: (pi) CMD (/home/pi/heartbeatgenerator.sh 2>&1)
Jan 7 13:05:01 RPi CRON[6334]: (CRON) info (No MTA installed, discarding output)
Jan 7 13:05:11 RPi pi: /home/pi/extase2influx/extase2influx.sh INFO: Database entry successfull. Written 1520 bytes
Jan 7 13:05:11 RPi CRON[6333]: (CRON) info (No MTA installed, discarding output)
Jan 7 13:05:12 RPi pi: /home/pi/ows2influx/ows2influx.sh INFO-OWS: Database entry successfull. Written 1456 bytes
Jan 7 13:05:12 RPi CRON[6332]: (CRON) info (No MTA installed, discarding output)
Jan 7 13:05:16 RPi dhcpcd[520]: wlan0: Router Advertisement from fe80::21d:aaff:feb0:8f20
Jan 7 13:05:20 RPi dhcpcd[520]: wlan0: Router Advertisement from fe80::21d:aaff:feb0:8f20
Jan 7 13:05:24 RPi dhcpcd[520]: wlan0: Router Advertisement from fe80::21d:aaff:feb0:8f20
Jan 7 13:06:01 RPi CRON[6566]: (pi) CMD (/home/pi/heartbeatgenerator.sh 2>&1)
Jan 7 13:06:01 RPi CRON[6562]: (CRON) info (No MTA installed, discarding output)
Jan 7 13:07:01 RPi CRON[6579]: (pi) CMD (/home/pi/heartbeatgenerator.sh 2>&1)
Jan 7 13:07:07 RPi CRON[6575]: (CRON) info (No MTA installed, discarding output)
Jan 7 13:07:54 RPi dhcpcd[520]: wlan0: Router Advertisement from fe80::21d:aaff:feb0:8f20
Jan 7 13:07:58 RPi dhcpcd[520]: wlan0: Router Advertisement from fe80::21d:aaff:feb0:8f20
Jan 7 13:08:01 RPi CRON[6608]: (pi) CMD (/home/pi/heartbeatgenerator.sh 2>&1)
Jan 7 13:08:02 RPi CRON[6604]: (CRON) info (No MTA installed, discarding output)
Jan 7 13:08:02 RPi dhcpcd[520]: wlan0: Router Advertisement from fe80::21d:aaff:feb0:8f20
Jan 7 13:09:00 RPi dhcpcd[520]: wlan0: Router Advertisement from fe80::21d:aaff:feb0:8f20
Jan 7 13:09:01 RPi CRON[6636]: (pi) CMD (/home/pi/heartbeatgenerator.sh 2>&1)
Jan 7 13:09:01 RPi CRON[6632]: (CRON) info (No MTA installed, discarding output)
Jan 7 13:09:04 RPi dhcpcd[520]: wlan0: Router Advertisement from fe80::21d:aaff:feb0:8f20
Jan 7 13:09:08 RPi dhcpcd[520]: wlan0: Router Advertisement from fe80::21d:aaff:feb0:8f20
Jan 7 13:10:01 RPi CRON[6672]: (pi) CMD (/home/pi/extase2influx/extase2influx.sh 2>&1)
Jan 7 13:10:01 RPi CRON[6673]: (pi) CMD (/home/pi/heartbeatgenerator.sh 2>&1)
Jan 7 13:10:01 RPi CRON[6674]: (pi) CMD (/home/pi/ows2influx/ows2influx.sh 2>&1)
Jan 7 13:10:06 RPi pi: /home/pi/extase2influx/extase2influx.sh INFO: Database entry successfull. Written 1490 bytes
Jan 7 13:10:06 RPi CRON[6661]: (CRON) info (No MTA installed, discarding output)
Jan 7 13:10:07 RPi CRON[6662]: (CRON) info (No MTA installed, discarding output)
Jan 7 13:10:12 RPi pi: /home/pi/ows2influx/ows2influx.sh INFO-OWS: Database entry successfull. Written 1376 bytes
Jan 7 13:10:12 RPi CRON[6660]: (CRON) info (No MTA installed, discarding output)
Jan 7 13:11:01 RPi CRON[6868]: (pi) CMD (/home/pi/heartbeatgenerator.sh 2>&1)
Jan 7 13:11:07 RPi CRON[6864]: (CRON) info (No MTA installed, discarding output)
I don't see anything strange and I don't see any reason why the cronjob heartbeat.sh fails at minute 08 and 09 of every hour.
Has some of you any clue?