Home Network Project
RSS icon Email icon Home icon
  • Mt. Redoubt explodes

    Posted on March 30th, 2009 lance No comments

    I live 40 miles north of Anchorage.  Lately Mt. Redoubt has been in a state of emotional turmoil.  She’s been rumbling and acting all angry and scary and such since January.  Every day at work I check into the Alaska Volcano Observatory website to check the status of this menace to society (or our little corner of it).

    I am able to see the latest seismic activity and a 24 hour webicorder which replaces the old drums.  Due to the fact that we’re a communications company for a majority of the state, but mostly for the south central region where Redoubt poses the greatest threat, we keep an eye on her status so we can dispatch appropriate personnel to deal with whatever equipment needs to be dealt with so our customers don’t lose their service.  Especially when the ash flies, that stuff will get into everywhere for weeks or months afterward.

    Well she blew on Sunday, March 22nd @ 10:38pm.  On my shift as well.  The wind blew south and northwest, keeping most of the ash away from most of civilization, with the exception of a couple small towns.  Since then, she’s puffing ash clouds maybe a couple times a day.

    After a few days of watching this, I decided to try out some scripting and my first cron job.

    The Task

    redoubt-webicorderSeeing the RSAM activity on a regular basis, gave me an idea.  Seeing that it was updated regularly, I thought it would be nice to capture that picture at a regular interval and save the filenames in a sequential name basis.  These I could then import into Adobe After Effects to make an animation of the seismic activity.  It was successful, except the video did not turn out as good as I had hoped.  The data is updated every 5 minutes and each line on the graphic is 30 minutes of data, so each updated had quite a bit of data and the video looked somewhat jumpy.

    The Script

    #!/bin/bash/

    y=`date +%Y%m%d%H%M`

    wget http://volcanoes.usgs.gov/avo/webicorders/NCT24hr_heli.png

    mv NCT24hr_heli.png /home/user/redoubt/$y.png

    It took me a little while (being one of my first bash scripts) to figure out why I could not get the variable y to be assigned the format of YYYYMMDDhhmm  (year, month, day, hour, minute).  Then after some scouring the ‘net, I found that I was using regular single quotes, not the other single quotes that never get used.  You know, the one with the tilde (~).  Once I found that and used it, SUCCESS!!

    So, from my script, we’ve got a variable assigned to the current date and time (to the minute) and then the next line downloads the graphic to the current directory.  What directory?  It doesn’t really matter, because we’re just going to move it to it’s own private location where it will be comforted by all it’s other friends.  That’s where the last line comes in.  We move it from the current directory to the new directory and give it a new name as well, one with the variable we created.   So each file will be in succession and named according to whatever date & time it was when it was retrieved.

    Enter the Cron Job

    Next, I had to have this script run automatically, because I did not feel like staying up all night running this every 5 minutes.  This is where the cron job comes into the scene.  I had to read some documentation on crontab to get this working.  Actually it was not too hard to figure out at all.  I just had to create a text file that tells when to run, and what command to run.  Then I get the cron job to read this file and all is well.  :-D Right?  Right!

    So, my text file reads as follows:

    00,05,10,15,20,25,30,35,40,45,50,55 * * * * bash /home/lance/redoubt.scr

    Wow, not so bad, right?  Okay, the easy part is on the right.  Basically it’s going to run the command there.  I want BASH to execute my REDOUBT.SCR script.  But what are all the numbers to the left? This diagram below helped alot.

    *    *    *    *      *       command to be executed
    -     –     -     -      -
    |     |     |     |     |
    |     |     |     |     +—– day of week (0 – 6) (Sunday=0)
    |     |     |     +——- month (1 – 12)
    |     |     +——— day of month (1 – 31)
    |     +———– hour (0 – 23)
    +————- min (0 – 59)

    Starting from the left is the minute to run, the hour, day of the month, month, day of week.  They are separated by spaces.  Now if you see my cron job has commas separating the numbers, that’s due to the fact that I want it to run multiple times during the hour.  If I could not set multiples, then I could only chose one time during the hour to run my cron job.

    This is handy if you want a job to run on the 1st and 16th of each month, or maybe 3 days of the week.  The possibilities are numerous.  I wont say endless, because I know someone will prove me wrong on that one.  :-)

    So to run this cron job, one needs to use crontab.

    You can see what crons are currently running with crontab -l.  You can remove crons with crontab -r.  To set ours, we just used crontab cron.txt.   After that I used the -l option to verify it was running.  After a quick directory listing of the redoubt directory, it verified that my script was working.

    Soon I had a plethora of png files and was able to create a short video. No, I’m not too proud of the video, but I am of successfully creating the script and cron job.

    Next Try

    Okay, so that worked.  Next job was to extract the RSAM images, because they scroll from rightRedoubt RSAM image to left and are updated every 10 minutes and move 1 pixel for each update.  This should provide a smoother video.

    So now I had to change my redoubt.scr file to extract a different image, so I changed:

    wget http://volcanoes.usgs.gov/avo/webicorders/NCT24hr_heli.png
    TO
    wget http://volcanoes.usgs.gov/avo/rsam/REF_EHZ_AV_5avg.png

    And the mv command had to reference the new saved image as well:  mv REF_EHZ_AV_5avg.png /home/lance/redoubt/$y.png

    Then I had to change my cron.txt file to run every 10 minutes:  00,10,20,30,40,50 * * * * bash /home/lance/redoubt.scr

    After a couple of days of capturing, I was able to put it together into a much smoother video.  Each peak on the graph represents an eruption.  The first occurring at 10:38pm local time on the 22nd.

    And so there it goes for my first set of scriptings and cron jobs.  More to come as I have need, or attempt to create more advanced ones.

    techno

    Comments are closed.