Skip to content

Commit

Permalink
improved timing to acquire images
Browse files Browse the repository at this point in the history
  • Loading branch information
onotch committed Jan 9, 2021
1 parent 5089f73 commit 4ea733e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cron.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5 0,3,6,9,12,15,18,21 * * * cd /Users/hoge/get_gpv/; /bin/sh get_gpv.sh
35 2,5,8,11,14,17,20,23 * * * cd /Users/hoge/get_gpv/; ./get_gpv.sh
32 changes: 16 additions & 16 deletions get_gpv.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,51 @@
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>0</integer>
<integer>2</integer>
<key>Minute</key>
<integer>5</integer>
<integer>35</integer>
</dict>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>5</integer>
<key>Minute</key>
<integer>35</integer>
</dict>
<dict>
<key>Hour</key>
<integer>6</integer>
<integer>8</integer>
<key>Minute</key>
<integer>5</integer>
<integer>35</integer>
</dict>
<dict>
<key>Hour</key>
<integer>9</integer>
<integer>11</integer>
<key>Minute</key>
<integer>5</integer>
<integer>35</integer>
</dict>
<dict>
<key>Hour</key>
<integer>12</integer>
<integer>14</integer>
<key>Minute</key>
<integer>5</integer>
<integer>35</integer>
</dict>
<dict>
<key>Hour</key>
<integer>15</integer>
<integer>17</integer>
<key>Minute</key>
<integer>5</integer>
<integer>35</integer>
</dict>
<dict>
<key>Hour</key>
<integer>18</integer>
<integer>20</integer>
<key>Minute</key>
<integer>5</integer>
<integer>35</integer>
</dict>
<dict>
<key>Hour</key>
<integer>21</integer>
<integer>23</integer>
<key>Minute</key>
<integer>5</integer>
<integer>35</integer>
</dict>
<key>WorkingDirectory</key>
<string>/Users/hoge/get_gpv</string>
Expand Down
17 changes: 9 additions & 8 deletions get_gpv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ if [ ! -d ${LOG_DIR} ]; then
mkdir -p ${LOG_DIR}
fi

year=`date -d '3 hours ago' +'%Y'`
month=`date -d '3 hours ago' +'%m'`
day=`date -d '3 hours ago' +'%d'`
hour=`date -d '3 hours ago' +'%H'`
hour_delta=$((`date +'%k'`%3+3))
year=`date -d "$((hour_delta)) hours ago" +"%Y"`
month=`date -d "$((hour_delta)) hours ago" +"%m"`
day=`date -d "$((hour_delta)) hours ago" +"%d"`
hour=`date -d "$((hour_delta)) hours ago" +"%k"`
log_file_path="${LOG_DIR}/error_log_`date +'%Y%m%d'`.txt"

for type in ${TYPE[@]}; do
for area in ${AREA[@]}; do
url_html=${GPV_URL}/msm_${type}_${area}_${year}${month}${day}${hour}.html
url_html=${GPV_URL}/msm_${type}_${area}_${year}${month}${day}`printf %02d ${hour}`.html
response=`curl -s -o ${TMP_HTML_FILE} -w "%{http_code}" ${url_html}`

if [ ${response} = "200" ]; then
Expand All @@ -50,9 +51,9 @@ for type in ${TYPE[@]}; do
mkdir -p ${save_dir}
fi

for ((i=1; i<=3; i++)); do
filename=`grep "fnl\[${i}\]" ${TMP_HTML_FILE} | awk -F'["]' '{print $2}'`
save_hour=`date -d "$((4-i)) hours ago" +"%H"`
for ((i=0; i<3; i++)); do
filename=`grep "fnl\[$((i+1))\]" ${TMP_HTML_FILE} | awk -F'["]' '{print $2}'`
save_hour=`printf %02d $((hour+i))`
save_file_path="${save_dir}/msm_${type}_${area}_${year}${month}${day}${save_hour}.png"

curl -s -o ${save_file_path} ${GPV_URL}/msm/${filename}
Expand Down

0 comments on commit 4ea733e

Please sign in to comment.