-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscheduler.sh
More file actions
executable file
·50 lines (31 loc) · 1.58 KB
/
scheduler.sh
File metadata and controls
executable file
·50 lines (31 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
### READ CONFIGURATION FILE
CONFIG_FILE="config.txt"
if [ ! -f $CONFIG_FILE ]; then
echo "Configuration file not found! Exiting..."
exit 1
fi
source $CONFIG_FILE
### GET SUNSET TIME
# Option #1: use R
sunset=`Rscript $ROOT/getSunsetTime.r`
echo "sunset: $sunset" >> $LOG_FILE
# Option #2: use web services
#todaydate=`date +%F`
#sunset=`curl -s "https://api.sunrise-sunset.org/json?lat=32.896244&lng=-117.242651&date=$todaydate&formatted=0" | jq -r '.results.sunset'`
### the above commands should be used to tun this script at a certain time using 'at'
executionTime=`date -d "$sunset -30 min" +"%Y%m%d%H%M"`
echo "`date`: Logging command to execute at: $executionTime" >> $LOG_FILE
### schedule photo capture
#echo "echo '`date`: Executing photo capture' >> /home/pi/SunsetCam/log" | at -t $executionTime
echo "bash /home/pi/SunsetCam/SunsetCam.sh -n 600 -a 0 -e 1 -d 0 -c 17 -m 'A #sunset #timelapse from @scrippsresearch' >> $LOG_FILE" | at -t $executionTime
### GET SUNRISE TIME
# Option #1: use R
sunrise=`Rscript $ROOT/getSunriseTime.r`
echo "sunrise: $sunrise" >> $LOG_FILE
### the above commands should be used to tun this script at a certain time using 'at'
executionTime=`date -d "$sunrise -20 min" +"%Y%m%d%H%M"`
echo "`date`: Logging command to execute at: $executionTime" >> $LOG_FILE
### schedule photo capture
#echo "echo '`date`: Executing photo capture' >> /home/pi/SunsetCam/log" | at -t $executionTime
echo "bash /home/pi/SunsetCam/SunsetCam.sh -a 0 -i 10 -n 240 -c 6 -e 1 -d 0 -m 'A #timelapse from @scrippsresearch' >> $LOG_FILE" | at -t $executionTime