#!/bin/bash # Edit these cap_script=/home/user/MyDocs/cap_script.sh cap_dir=/var/tmp an_script=/home/user/MyDocs/animate_script.sh output_anim= $cap_dir/output_animation.gif every_N_min=20 between_hour="11-12" #################### # Make capture script echo " #!/bin/bash phone-control --capture $cap_dir/`date +%Y_%m_%d-%H_%M_%S`.jpg " > $cap_script # copy+backup current crontab crontab -l > old_cron.txt cp old_cron.txt current_cron.txt # Make the animate script that also restores the previous cron (and deletes the timelapse job) echo " #!/bin/bash convert -delay 20 -loop 0 $cap_dir/*.jpg $output_anim crontab old_cron.txt rm old_cron.txt " > $an_script # The following will execute the capture script "every N minutes" between the hours of "between_hour" just for today echo "#min hour dom mon dow year" >> current_cron.txt echo " */$every_N_min $between_hour `date +%d\ %m\ %w\ %Y` $cap_script >> current_cron.txt # Add animation script an hour after it runs to cron echo " 0 $(( `echo $between_hour | egrep "[0-9]+$"` + 1 )) `date +%d\ %m\ %w\ %Y` $an_script >> current_cron.txt # Write new crontab crontab current_cron.txt rm current_cron.txt