diff --git a/run_speed_test.sh b/run_speed_test.sh index 61d55a8..ce0c983 100755 --- a/run_speed_test.sh +++ b/run_speed_test.sh @@ -24,6 +24,8 @@ tail -6 ${RAW_DATA} > ${TMP_DATA} && \ tail -1000 ${RAW_DATA} > ${TMP_DATA} && \ cp ${TMP_DATA} ${RAW_DATA} +echo "[$(date)] Updated speed data" + # Above arguments produce the following output in single line. Expanded for readability below: # # { diff --git a/start.sh b/start.sh index b6fb8b0..1eb2d37 100644 --- a/start.sh +++ b/start.sh @@ -18,14 +18,14 @@ chmod -R a+rwX /var/www/data || true # Run the initial speed test once (in background) to populate files if possible # We run it in background so server starts promptly. The cron will run hourly. -/usr/local/bin/run_speed_test.sh || true & +/usr/local/bin/run_speed_test.sh >> /var/log/cron.log 2>&1 || true & # Ensure the cron job exists in Cron CRON_FILE=/etc/cron.d/speedtest-cron -if grep run_speed_test ${CRON_FILE}; then +if [ -f ${CRON_FILE} ] && grep run_speed_test ${CRON_FILE}; then echo "cron entry already present" else - echo ${CRON_MINUTE} '* * * * /usr/local/bin/run_speed_test.sh >> /var/log/cron.log 2>&1' > ${CRON_FILE} + echo ${CRON_MINUTE} '* * * * root /usr/local/bin/run_speed_test.sh >> /var/log/cron.log 2>&1' > ${CRON_FILE} fi # Start Debian cron in background