Let's think about it this way for a second
This lesson isn't about any single skill in isolation — it's a set of scenario-based tasks that combine the shell scripting, process management, cron, disk, ssh/scp/rsync, systemd, and log troubleshooting skills you learned across the Intermediate/Advanced chapters. It simulates the kinds of problems a real server operator runs into every day — 'a process isn't running,' 'disk space is running out,' 'I need to send a file to a remote server.' The difficulty ramps up step by step from Task 1 through Task 4 — the last task will test your troubleshooting mindset too. Read the output carefully after each command before moving on to the next step.
Practice exercises
Task 1: run a process in the background (for example, sleep 500 &), and write a check-process.sh script that looks for that process name with ps aux | grep and prints "Running" if it's running, or "Not running" if it isn't. Task 2: schedule the script above to run every 5 minutes with crontab -e, and append (>>) its result to ~/check.log. Task 3: under /var/log (or any log directory you have permission for), find the 5 largest files with du -ah | sort -rh | head -5, then archive with tar -czf and delete any log files older than 7 days (combine find ... -mtime +7 with tar/rm). Task 4: set up passwordless SSH with ssh-keygen + ssh-copy-id to a local test user account (or a home VM/VPS), then use rsync -avz to sync an entire folder to the remote — once synced, compare checksums with ssh remote-host "md5sum file" against the local one.
Code example
#!/bin/bash
# check-process.sh — Task 1 & 2
PROCESS_NAME="sleep"
if ps aux | grep -v grep | grep -q "$PROCESS_NAME"; then
echo "$(date): $PROCESS_NAME is Running" >> ~/check.log
else
echo "$(date): $PROCESS_NAME is NOT running" >> ~/check.log
fi
# crontab -e ထဲမှာ ဒီလို ထည့်ပါ (5 မိနစ်တစ်ခါ):
# */5 * * * * /bin/bash ~/check-process.sh
# Task 3: largest files + old log archive
du -ah /var/log 2>/dev/null | sort -rh | head -5
find /var/log -type f -mtime +7 -print0 | tar -czvf old-logs.tar.gz --null -T -
find /var/log -type f -mtime +7 -delete
# Task 4: passwordless SSH + rsync sync
ssh-keygen -t ed25519 -f ~/.ssh/practice_key -N ""
ssh-copy-id -i ~/.ssh/practice_key.pub user@remote-host
rsync -avz -e "ssh -i ~/.ssh/practice_key" ~/practice-lab/ user@remote-host:~/practice-lab-copy/check.log fills up with timestamped process status entries, old-logs.tar.gz contains the archived log files older than 7 days, and the practice-lab-copy folder is fully synced on remote-host.5-minute try-it
Within 5 minutes, change check-process.sh to use PROCESS_NAME="nonexistent123" and run it, then watch tail -f ~/check.log live to confirm the log correctly records the Not running status.
One thing to watch out for
Don't try find ... -delete or tar archive commands directly on a production log directory — create a test folder and practice there first, since messing with real /var/log can wipe out your system's log history.