0
I have a script that encodes a video every day (cron job) and this video is uploaded to youtube just after its creation. Although sometimes these scripts fail.
How can i make the script to retry these two commands if one of them or both fail ?
The script:
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
echo $(date)
cd /home/pi/
ls *.jpg > stills.txt
DATE=$(date --date=yesterday +"%Y-%m-%d")
three_days_ago=$(date --date="3 days ago" "+%m-%d")
yesterday=$(date --date yesterday "+%m-%d")
video_name=$(date +"%m-%d")
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o $yesterday.avi -mf type=jpeg:fps=10 mf://@stills.txt
video_link=$(youtube-upload --email=xxx --password=xxx--title="Timelapse Video of "$yesterday --description="Heraklion Timelapse Video of "$yesterday \
--category=Tech --keywords="Raspberry PI, Timelapse" /home/pi/$yesterday.avi)
echo $video_link
youtube-upload --email=xxx --password=xxx--add-to-playlist http://gdata.youtube.com/feeds/api/playlists/PLbjjzh8UkLN2pQTZwXyQ4kP2bXb7Zwtmo $video_link
echo $(date)
/home/pi/Desktop/camera/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/Desktop/camera/video_maker.log /Public/pi_videos
find . -type f -name $DATE\* -exec rm {} \;
rm $three_days_ago.avi
The commands i want to implement it are
- mencoder -nosound....
- video_link=$(youtube-upload --email=xxx...
Can you explain me what does this means? if [ $? == 0 ];then break – Manos – 2014-10-17T15:43:44.397
I have edited my answer to explain this a little. – Isaac – 2014-10-20T06:29:07.073