Practice & Assessment
Test your understanding of Process Management and Automation
Multiple Choice Questions
5What does `wait $pid1; status1=$?` accomplish in a Bash script?
Which signal cannot be trapped or caught by a Bash script?
Why must cron jobs use absolute paths or set PATH explicitly?
What does `kill -0 $pid` do in Bash?
What advantage does `xargs -P 4` have over running 4 explicit background jobs with `&`?
Coding Challenges
1Parallel File Processor
Write `parallel-process.sh` that accepts a directory as `$1`, a worker count as `$2`, and a command as `$3`. Find all regular files in the directory, process them using `xargs -P $2` by running `$3` on each file, and collect the exit codes. At the end, print how many files succeeded and how many failed. Implement a `--dry-run` flag that prints what would be executed without running. Use a `trap INT TERM` to kill all xargs children cleanly. Input: directory path, integer worker count, command string. Output: per-file status and final summary. Time estimate: 25-30 minutes.
Mini Project
Service Health Monitor
Build `monitor.sh` — a daemon-style script that monitors a list of services. Read service URLs from a config file (one URL per line, format `name=URL`). Every N seconds (configurable, default 30), curl each URL in parallel using background jobs with controlled concurrency. Log each result (status code, response time) using the structured logging library from module 3. Write a PID file on start and remove it on exit. Handle SIGTERM for graceful shutdown and SIGHUP to reload the config without restarting. Maintain a running count of consecutive failures per service and trigger a configurable alert command when a threshold is crossed. Schedule the monitor using a systemd timer unit file.
