Created
May 18, 2020 16:02
-
-
Save garbled1/923da622c5525148f868c5d7fd048f84 to your computer and use it in GitHub Desktop.
Bash script to run something at dawn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
civ_tw=$(curl -s 'https://api.sunrise-sunset.org/json?lat=X&lng=Y&date=today&formatted=0' | json_pp | grep civil_twilight_begin | awk '{print $3}' | sed -e 's/[",]//g') | |
date_sec_ct=$(date -d ${civ_tw} +%s) | |
date_now=$(date +%s) | |
sleepsec=$((${date_sec_ct} - ${date_now})) | |
end_at=$((${date_sec_ct} + 3600)) | |
echo "Sleeping for ${sleepsec}" | |
sleep ${sleepsec} | |
cd ~/dawn | |
while /usr/bin/true | |
do | |
fn=$(date +%H.%M.%S.jpg) | |
ffmpeg -y -rtsp_transport tcp -i rtsp://X.X.X.X:5000/stream0 -vframes 1 ~/dawn/${fn} | |
now=$(date +%s) | |
if [ ${now} -gt ${end_at} ]; then | |
exit 0 | |
fi | |
sleep 30 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment