Makefile Build Automation: More Than Just Compilation

Overview Many people think of Makefile as merely a build assistant for C/C++. But Make is fundamentally a dependency-driven task execution engine — you tell it “what the target is, what it depends on, and how to generate it,” and it handles executing in the correct order while skipping steps that don’t need repeating. This model is equally powerful in ops scenarios: deployment depends on build, cleanup depends on service shutdown, checks depend on configuration being ready....

March 26, 2024 · 14 mins · 2964 words · XuBaojin

Scheduled Task Management: cron vs systemd timer

Overview Scheduled tasks are a foundational component of operations automation — log rotation, data backups, certificate renewal, health checks, report generation — nearly every ops scenario relies on scheduled execution. Most people’s understanding of scheduled tasks stops at crontab -e plus a line like 0 2 * * * /path/to/script.sh, but this is far from sufficient in production: who gets notified when a task fails? Who handles execution timeouts? How do you coordinate tasks across multiple machines?...

March 18, 2024 · 21 mins · 4276 words · XuBaojin

kubectl Productivity Guide: Plugins and Aliases

Overview kubectl is the most commonly used tool for Kubernetes administrators, yet most people only use 20% of its capabilities. You type kubectl get pods -n production dozens of times a day without realizing a single alias can cut the keystrokes in half. When problems arise, you only know kubectl describe and kubectl logs, unaware that krew plugins can troubleshoot network, resource, and certificate issues with a single command. This article systematically covers the kubectl productivity toolchain — from aliases to plugins to interactive tools — to double your daily K8s operation efficiency....

March 12, 2024 · 17 mins · 3535 words · XuBaojin

Practical Shell Script Automation Tips

Introduction Shell scripts are the most common automation tool for operations engineers. This post records several practical patterns used in the field. Log Rotation Cleanup #!/bin/bash # clean_logs.sh - Log cleanup script LOG_DIR="/var/log/app" KEEP_DAYS=30 find "$LOG_DIR" -name "*.log" -type f -mtime +${KEEP_DAYS} -exec gzip {} \; find "$LOG_DIR" -name "*.gz" -type f -mtime +${KEEP_DAYS} -delete echo "$(date): Log cleanup complete, kept ${KEEP_DAYS} days" Run daily via crontab: 0 2 * * * /opt/scripts/clean_logs....

January 11, 2024 · 2 mins · 369 words · XuBaojin

Production-Grade Bash Scripting Guide

Overview Bash is the most widely used scripting language in the ops world — nearly every Linux server ships with the interpreter, requiring no runtime installation. But Bash is also the language most prone to producing scripts that “work but can’t be trusted”: no type checking, errors are silent by default, variables get word-split without quotes, and pipeline failures get swallowed. The root cause of many production incidents is a Bash script that didn’t handle errors properly....

December 27, 2023 · 22 mins · 4514 words · XuBaojin