This post is to demonstrate the simplest way to set up your personal Weather Forecast Email Service using basic Linux Bash Scripts and Cron job. You can put scripts on your VPS, your Rasberry PI, or any other form of Linux server.
- Operation System: Operating System: CentOS Linux 7 (Core)
- Kernel: Linux 3.10.
- Weather Forecast Source: Australian Bureau of Meteorology, please be aware of the Copyright Statement on BoM’s website, which I will list at the end of the article.
Create your download Script for the Weather Information
- Create a file/bash script, let us call it monitor, if you are not familar with Vi, you can use nano or any other text editor instead
- Put below text in, you can see it is very straightforward, download the weather forcast information, sleep for 5 seconds then exit.
#Update the Weather
wget -nv –output-document=/monitor/IDW12300.txt ftp://ftp2.bom.gov.au/anon/gen/fwo/IDW12300.txt
Note: you can find the Capital City list here:
- Canberra = IDN10035
- Melbourne = IDV10450
- Brisbane = IDQ10095
- Perth = IDW12300
- Hobart = IDT13600
Create your email sending script
- Similar to above, create a new script using your favourite text editor
- Put below content in
#ICT Fella’s free weather forecast service
/bin/mailx -r [email protected] -s “ICT Fella Weather Forecast” [email protected] [email protected] < /monitor/IDW12300.txt
- Setup Cron job, for people familar with Linux, Cron is a handy “Task Scheduler” (if you are talking Windows) in Linux word
Add 2 lines in to run the scripts every day, download the weather forecast at 6:30AM, then send the forecast at 6:44:
30 6 * * * root /root/monitor
44 6 * * * root /root/weather
It is that simple, the reason I split into 2 scripts is I do have a bunch of other tasks running in them ( such as monitoring hardware usage, monitoring Currency exchange rate), separation out makes me have more leverage of each component. This dummy Email Service has been running for the past 8 years thanks to BoM’s awesome free FTP service.
An email will be something like below:
BoM websites and Copyright Statement: http://www.bom.gov.au/catalogue/anon-ftp.shtml
SirLeech’s GitHub https://github.com/sirleech/weather_feed