Details
Goals & objectives
Hardware & software
Solution overview
In this lab you start from a rough bash script with the same block of code pasted three times and turn it into a log rotation tool you would trust in production. You pull the repeated code into functions, keep the list of log files in a properly quoted array so a filename with spaces stops breaking the loop, add a trap so an interrupted run leaves no temporary files behind, and give the script real command-line options with getopts and meaningful exit codes. Then you chase a live bug with set -x, run shellcheck over the finished script, and schedule it two ways, once as a cron entry and once as a systemd timer, so the difference between the two schedulers shows up on a job you wrote yourself.