bashcron

Crontab task scheduled every hour stops running from 11am to 12am


I have a rather weird issue. My aim is to use ffmpeg to grab a screenshot from a home CCTV cameras rtsp stream every hour. I want to do this in order to make a timelapse. However everyday from 11am to 12am (the next day) there are no snapshots saved.

On an always on Debian machine, this is the shell script I have that crontab calls:

dt=$(date +"%d%m%2y%I%M%S")
ffmpeg -rtsp_transport tcp -i "rtsp://IP:554/..." -frames 1 /user/snapshots/ch1/$dt.jpg

Running it by itself works fine and saves a jpg snapshot successfully to the right folders.

In crontab -e I have the following line: 0 * * * * /bin/sh //user/snap.sh

Thanks.


Solution

  • %I is the hour on a 12-hour clock (intended to be used with %p), so your afternoon files are overwriting the morning ones. Use %H instead.