I recently started a new job so I will not be posting as much now unfortunately. I am trying to decide how I want the script that uses at to function. The problem is that if the power was consistent that script that is the last one in this post would work beautifully. However since power may not be on 100% of the time because of a snow storm or something else knocks the power out, this script may not function the way it should. If the power is off when the script was scheduled to run, it will run whenever the system starts up, not at the correct time. And this is a major problem. So my next idea was to set all of the times that the camera would take a picture for the whole year. This script accomplishes that.
# this script will set all of the times when
# the camera should take a picture.
# set some variables
# test how many times this script should execute
# I chose 400 because there is 365 days in a year
# and this is a little more than that
while [ $count -lt 400 ]
# set what time at should execute the script
at -f /root/camera_1443min now + $min’min’
# add 1 day and 3 minutes to the last time
# 1440min = 1day
min=$((min + 1443))
# increment the count by one
count=$((count + 1))
The main problem with this script is that if the power is off, and it misses one or more of these scheduled time, it will execute them when the computer boots. The problem with this is that I will have pictures in the folder along with all of the rest of them that were not taken at the right time. Still trying to figure out how to deal with that. If at had configuration files that would turn “execute old jobs at boot” on and off that would be nice! The other option is to assume that the power will only go out once or twice, and that I should not worry about it, and write a script that executes at startup to put the date and time into a file. Then I could get the date and time from that file and go find the images that were taken at the wrong time.
I ask this question on the Unix/Linux Stack Exchange forum and I am waiting to see if there are any answers that will work.
NOTE: This is kinda complicated to explain in text so I did my best. Leave a comment below if you have questions!