Write a Bash script that:
- Fetches current weather in Pune from a public API
- Extracts the weather condition and temperature
- Logs personalized advice (e.g., “Carry umbrella ☔” or “Wear sunscreen 😎”)
- Runs every hour automatically using
cron
-
Make the script executable:
chmod +x weather_notify.sh
-
Run it manually:
./weather_notify.sh
-
Check the weather log:
cat ~/weather.log
-
Schedule it to run every hour using
cron
:crontab -e
Add this line:
0 * * * * /full/path/to/weather_notify.sh
[2025-07-12 13:00] Pune: Sunny +34°C — Wear sunglasses 😎 and sunscreen 🧴
[2025-07-12 14:00] Pune: Light rain +28°C — Carry an umbrella ☔
Feature | Real-Life Use Case |
---|---|
curl |
Consuming APIs in scripts |
awk , case |
Text parsing + conditional logic |
cron |
Background scheduling for automation |
Logging | Creating traceable audit reports |
- Monitor weather in multiple cities with a loop
- Use
notify-send
for desktop notifications (Linux GUI) - Send messages via Telegram bot or Slack webhook
- Add sound alerts for rain using
aplay
ormpg123
This script introduces you to API integration and job scheduling — two key building blocks in automation, DevOps, and real-time alerting systems.
“The same tools used to monitor a Kubernetes cluster can help you decide when to carry a raincoat.” ☔