Bash & Linux·Bash from first command to automation

Automation project

Automate a weekly report with safe scripting and logging.

Beginner 22 min read Lesson 10 of 300 Challenge included
What you will be able to do
  • Log every run with a timestamp.
  • Fail loudly and exit non-zero.
  • Write output atomically.
  • Schedule with cron or a systemd timer.

In plain English

The capstone combines navigation, text processing, pipes, scripts and cron. Write a script that reads a data file, produces a summary, writes a log and exits non-zero on failure. Schedule it and verify the result.

weekly-report.shTerminal
#!/usr/bin/env bash
set -euo pipefail

log="report-$(date +%F).log"
{
  echo "run: $(date -Is)"
  awk -F, '{ total += $2 } END { print "total minutes:", total }' minutes.csv
} | tee "$log"
Your turn

Log with a timestamp

Easy

Write a line starting with the ISO timestamp to report.log.

BASH · starter
echo "done"
Check your understanding before moving on.
Knowledge checkQuestion 1

Why use absolute paths in cron scripts?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 10 of 300 · 0% of course