Hands-on task
Yesterday's logs archive
The shop's logs for the past day have to be packed every night. Write a script /usr/local/bin/archive-yesterday that packs the /var/log/shop directory into /srv/archive/shop-YYYY-MM-DD.tar.gz, where the date is yesterday's (a run at 00:05 belongs to the day that just ended). The script creates the /srv/archive directory itself. Don't type the date by hand. Run the script. It's handy to write the script in the Editor tab above the terminal — the /usr/local/bin directory is open on the left there.
- date -d
- relative dates
- command substitution
- tar
- mkdir -p