1

Running Ubuntu 19.10

I have reviewed the wiki on crontab scripts but I am still unsure why mine is not starting. The bash script I would like to run is here:

#!/bin/bash
now_hour=$(date "+%H")

while ((now_hour < 21))
do
    start_time=$(date "+%d.%m.%Y-%H:%M:%S")
    status=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null  && echo ok || echo error)

    if [ "$status" == "ok" ]
    then
        timeout 30m vlc -vvv http://10.0.0.113:8000/stream.mjpg --sout="#std{acces=file,mux=ogg,dst=/home/whsrobotics/KestrelCam/Recordings/Kestrel_Box:$start_time.mp4}"
        echo "$start_time,recording_started" | tee -a "/home/whsrobotics/KestrelCam/log.txt"
    else
        echo "$start_time,network_problem" | tee -a "/home/whsrobotics/KestrelCam/log.txt"
        sleep 5m
    fi
    now_hour=$(date "+%H")
done

My crontab file is here:

# crontab -e
SHELL=/bin/bash

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

# start the Kestrel Camera recording at 5:00 am every day (will run to at least 9:00 pm)
00 05 * * * /home/whsrobotics/KestrelCam/all_day

The script works as intended when manually started in the terminal but not from cron. I have a suspicion that it may be the PATH but I am not sure how to address that. Any suggestions here are appreciated.

SteveC
  • 253

0 Answers0