Level: Intermediate · Time: 7 min · Outcome: A mental model and three guards for unattended cron jobs
There's a gap between a script that works when you run it and a script that survives running unattended for a year. The first only has to succeed o...
Three Lines of Bash Stand Between Your Cron Job and a Silent Outage
Level: Intermediate · Time: 6 min · Outcome: A hardened, ShellCheck-clean cron wrapper generated for you
Three separate incidents taught me the same lesson over about a year. A /1...
A /1 rsync took our staging box to a load average of 41 one afternoon, and it took me longer than I want to admit to work out why. The sync normally finished in about twenty seconds. That day the backup target's NFS mount went sluggish, the sync star...
I meant to delete the .cache files under a data directory. The server had been running for two months and the cache layer had grown to about 14GB. The application team told me it was safe to purge it — they'd rebuilt the cache logic and the old files...
A backup script of mine created a lock file on startup so two copies couldn't run at once — sensible. Then one night it hit an error partway through, set -e killed it on the spot, and it died without ever reaching the line that removes the lock. The ...
Every time I provision a new server — whether it's a $5 DigitalOcean droplet for a side project or a client's production box — there's a set of scripts I copy to /opt/scripts before I do anything else.
Not after the app is deployed. Not after the fi...
Nobody announces small features. You ship them, they're in there, and the people who find them either notice or they don't. I want to start documenting these because some of them are the kind of thing that makes a tool actually worth using day-to-day...
ShellCheck Error Codes Explained: How to Decode, Fix, and Prevent the Most Common Bash Warnings
Level: Beginner to Intermediate
Time: ~10 minutes
What you'll leave with: A clear understanding of ShellCheck's error code system, how to fix the on...
Here's how it usually goes:
You deploy something. Traffic is light. Server load sits at 15% and you move on to the next thing. Then traffic grows, or a cron job stacks on itself, or a memory leak slowly eats through your RAM over 72 hours. By the ti...
I Google "bash remove file extension" at least once a month.
Every time I need ${filename%.txt} I have to look it up. I've written that exact syntax probably 40 times across different scripts. My brain refuses to memorize it. And every time I need i...
Every experienced Linux user has been there: you install something, or move directories around, and suddenly command not found appears for tools you know are installed.
You check which, type, echo $PATH, and still waste 10-20 minutes hunting down th...
The Problem
You're setting file permissions and you type chmod 754... or was it 744? You Google it. Again.
Or you're starting a new bash script and you copy the header block from your last script because you can't remember the exact set -euo pipef...
The Problem
You're deploying a script and need the right file permissions. You type chmod 754... or was it 744? You Google it. You find a Stack Overflow thread from 2011. You get it wrong anyway.
chmod's octal notation is one of those things every...
Cron job tutorials have a problem. They teach you the five-field syntax, show you a couple of examples like 0 2 , and send you on your way. What they don't cover is everything that needs to go around the expression for the job to actually work rel...