10 curl Commands Every Sysadmin Should Automate to Save Hours of Work

Ever catch yourself doing the same boring server checks every single morning? Same here—until I started scripting those chores away with a tool that’s already on every Linux box: curl. Most people think it’s just for downloading files or poking a website, but it’s actually a Swiss-army knife for talking to APIs, monitoring services, and pushing data around—all from the command line.

Below you’ll find 10 curl one-liners I still lean on every week. Copy-paste them into a shell script, cron them, and suddenly you’re the hero who “fixed” the 7 a.m. status check.

1. Quick Server Health Check
curl -I https://yourdomain.com | head -1
Shows the HTTP status line; 200 means all good.

2. Download Files Without wget
curl -O https://yourdomain.com/latest.tar.gz
Pulls the file using the same name as the remote.

3. Upload via HTTP PUT
curl -T backup.zip https://yourdomain.com/upload
Pushes the file straight to an endpoint that expects PUT.

4. Follow Redirects Automatically
curl -LIs https://yourdomain.com | grep “HTTP”
Great for making sure HTTP→HTTPS redirects actually work.

5. Grab JSON from an API
curl -s https://api.yourdomain.com/stats | jq .
Add jq for pretty printing.

6. Push JSON to an API
curl -X POST -H “Content-Type: application/json” -d ‘{“uptime”:true}’ https://api.yourdomain.com/push

7. HTTP Basic Auth in One Line
curl -u user:pass https://yourdomain.com/protected
No need to craft Base64 headers yourself.

8. Fake a Different User-Agent
curl -A “Mozilla/5.0 (Mobile)” https://yourdomain.com
Useful for mobile testing or scraping picky CDN endpoints.

9. Silent Mode + Error Checking
curl -sf https://yourdomain.com/health || echo “Site down”
-s silences, -f makes curl return error on HTTP 4xx/5xx.

10. Filter Output Inline
curl -s https://api.yourdomain.com/info | grep “version”
Chain with grep, sed, awk—whatever you like.

Putting It All Together

Step 1 – List Every Repetitive Task
Write down anything you type more than twice a day: checking health endpoints, downloading logs, posting metrics to Slack.

Step 2 – Map One-Liners to Tasks
Pick the snippet above that matches each chore.

Step 3 – Stitch Them Into a Script

#!/bin/bash
STATUS=$(curl -sf https://yourdomain.com/health)
if [ $? -ne 0 ]; then
  echo "Site down" | mail -s "Alert" [email protected]
fi

Step 4 – Test It Manually
Run the script by hand once. Fix any path or permission issues before you schedule it.

Step 5 – Cron It
Run crontab -e and drop in:
0 7 * * * /opt/scripts/health_check.sh
Now you’re sleeping in while the script does the 7 a.m. check for you.

Pro Tips

• Use -s to keep cron emails clean.
• Pipe JSON responses into jq for prettier logs.
• Always log stdout/stderr so you know what failed:
0 7 * * * /opt/scripts/health_check.sh >> /var/log/health.log 2>&1

What’s Next?

Start small—automate one task today. Once you taste that “set it and forget it” life, you’ll end up scripting the whole checklist. Drop your favorite curl hack in the comments; I’m always looking for new tricks to steal.

Related: 🛠️ Master Automation with Curl: 10 Essential Commands for Every Sysadmin 🛠️.

Related: Automate your work with google vision and AI.


Discover more from Susiloharjo

Subscribe to get the latest posts sent to your email.

Discover more from Susiloharjo

Subscribe now to keep reading and get access to the full archive.

Continue reading