# Lab7 Solution Amirlan Sharipov (BS21-CS-01)

## Table of Contents

- 1. Question 1
  - 1.1. Cron job
  - 1.2. Anacron
- 2. Question 2
  - 2.1. Cron job
- 3. Question 3

## 1. Question 1

### 1.1. Cron job

0 0 */5 * * /home/rinri/edu/sna/backup.sh

    cat backup.sh

    FNAME="$(date '+/home/rinri/edu/sna/funny-dir_%b_%d_%Y_%H_%M_%S.tar.gz')"
    tar caf "$FNAME" /home/rinri/edu/sna/funny-dir

### 1.2. Anacron

1 10 backup-anacron /home/rinri/edu/sna/backup-anacron.sh

    cat backup-anacron.sh

    #!/bin/bash
    rm /home/rinri/edu/sna/funny-dir_*
    FNAME="$(date '+/home/rinri/edu/sna/funny-dir_%b_%d_%Y_%H_%M_%S.tar.gz')"
    tar caf "$FNAME" /home/rinri/edu/sna/funny-dir

## 2. Question 2

### 2.1. Cron job

0 0 * * 0 /home/rinri/edu/sna/backup-nginx.sh

    cat backup-nginx.sh

    #!/bin/bash
    rm /home/rinri/edu/sna/nginx-www_*
    FNAME="$(date '+/home/rinri/edu/sna/nginx-www_%b_%d_%Y_%H_%M_%S.tar.gz')"
    tar caf "$FNAME" /var/www/

## 3. Question 3

5 * * * * /home/rinri/edu/sna/log-info.sh “5 minutes after midnight everyday”

0 10 * * 1-5 /home/rinri/edu/sna/log-info.sh “10:00 on weekdays”

0 4 * * 1 /home/rinri/edu/sna/log-info.sh “4:00 on Monday”

0 0 8-14 * 6 /home/rinri/edu/sna/log-info.sh “second saturday of the month”

    cat log-info.sh

    #!/bin/bash
    echo "$(date '+%d-%m-%y %H:%M:%S') $1" >> /var/log/sna_cron.log

Author: Amirlan Sharipov (BS21-CS-01)

Created: 2023-03-16 Thu 23:57