Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We will create a script, copy it into our / etc / cron . daily / directory to force it to run at midnight each

We will create a script, copy it into our /etc/cron.daily/ directory to force it to run at midnight each night, and set up your user's crontab to run the script at 12 minutes past the hour each hour Monday through Saturday. I will assist you with writing the script. It will be a super simple script that runs the 'rsync' command (remote synchronizes) one directory's contents to another on your system. Here are the steps to complete this problem set.
Log into your virtual machine (either Ubuntu Desktop, Ubuntu Server, or Rocky 8) and open your command console terminal. You should be in your home directory.
Move into your scripts directory (/home/username/scripts/)
Create a directory named work in your /home/username/(/home/username/work/)
Create a directory named backup in your /home/username/(/home/username/backup/)
Move into your home directory (/home/username). Use the 'ls' command to list all sub-directories of your home directory.
Move into the /home/username/work directory
Use VIM to create a file named sys-doc.txt, enter your name, today's date, and your CCU email address in the document, then save and exit.
Move into the /home/username/scripts directory with 'cd'
Use VIM to create a script file named rsync-work-stuff.sh that performs an rsync (with the archive, verbose, show progress bar, and human-readable options) of the /home/username/work/ directory contents to the /home/username/backup/ directory. Be sure to include the shebang line at the top (#!/bin/bash) and add at least one line of comments explaining what the script does. Search 'man rsync' online to get the manual pages for the command and the options (archive, verbose, progress bar, human-readable) as well as the syntax in the command. The general syntax is $ rsync [options][source][destination]. Be sure to use absolute source and destination locations. Make sure you include the typical header information for all BASH scripts, those you used in the previous module.
Save the file and exit VIM. Make the script executable so cron can run the script. To do this, use the 'chmod +x rsync-work-stuff.sh'. This will allow all users to execute the script.
CAT out the contents of the 'rsync-work-stuff.sh' script to the screen using the 'cat /home/username/scripts/rsync-work-stuff.sh' command. This will display the contents of the script. Capture a screenshot using the "Create Screenshot Package" option in TealVirt. Make sure you can see the command you executed and the output showing showing the rsync-work.sh script information. This will be screenshot #1 of the assignment.
To have this script execute each day at midnight, we need to either put a copy of this script in the /etc/cron.daily/ directory or create a crontab entry with the appropriate time specifications (or using @daily). Copy the /home/username/scripts/rsync-work-stuff.sh script to your /etc/cron.daily/ directory.
Perform a long listing of the /etc/cron.daily/ directory. You should see your rsync-work-stuff.sh script with its permissions, owner, etc....
You should still be in your /home/username/scripts/ directory. If not, go there now.
Add the rsync-work-stuff.sh script to your the root user's crontab. This script should execute at 12 minutes past each hour of the day, Monday through Saturday. Save and exit the crontab editing window, this will install the new crontab entry.
View root's crontab entries. Capture a screenshot using the "Create Screenshot Package" option in TealVirt. Make sure you are viewing root's crontab showing the rsync-work-stuff.sh script being ran from your /home/username/scripts/ directory at 12 minutes past every hour Monday through Saturday. Please use crontab.guru website to check your crontab entry. This will be screenshot #2 of the assignment.
Wait until 12 minutes past the nearest hour or the next day. Move into your /home/username/backup/ directory. There should be an rsync'd copy of the sys-doc.txt file there from either the /etc/cron.daily/ directory executing the script, or the crontab executing the script at 12 minutes past the hour. Perform a long listing of your /home/username/backup/ directory. Capture a screenshot using the "Create Screenshot Package" option in TealVirt showing the rsync'd copy of sys-doc.txt. This will be screenshot #3 of the assignment.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is a cost driver? Give three examples. ph5

Answered: 1 week ago

Question

Which form of proof do you find most persuasive? Why?

Answered: 1 week ago