Chapter 5: Bash Scripting for Automation
5.1 Why script — the morning ten commands
Every morning you type the same checks: go to the app folder, pull latest, hit health URL, restart if needed. That is a script waiting to be born.
A Bash script is a text file of shell commands the Bash interpreter runs in order. Automation starts here before Ansible or CI.
Why it matters for an Instagram-style badge API : a tiny health_restart.sh can curl the badge API health counter and restart the service if lunch-hour checks fail — same steps every time, written down.
| Manual typing | Script |
|---|---|
| Easy to skip a step | Order is fixed in the file |
| Hard to hand to a teammate | README can say ./health_restart.sh --dry-run |
| Typos under stress | Tested once, reused many times |
Ravindra Bagale's Tip
Khup students mothya Ansible / Jenkins kade jump kartat aani simple Bash nahi shiktat. Interview madhe ek chota script explain karta aala pahije. Foundations first. Dhyan rakho!