Answered step by step
Verified Expert Solution
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 etccrondaily directory to force it to run at midnight each night, and set up your user's crontab to run the script at 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 and open your command console terminal. You should be in your home directory.
Move into your scripts directory homeusernamescripts
Create a directory named work in your homeusernamehomeusernamework
Create a directory named backup in your homeusernamehomeusernamebackup
Move into your home directory homeusername Use the ls command to list all subdirectories of your home directory.
Move into the homeusernamework directory
Use VIM to create a file named sysdoc.txt enter your name, today's date, and your CCU email address in the document, then save and exit.
Move into the homeusernamescripts directory with cd
Use VIM to create a script file named rsyncworkstuff.sh that performs an rsync with the archive, verbose, show progress bar, and humanreadable options of the homeusernamework directory contents to the homeusernamebackup directory. Be sure to include the shebang line at the top #binbash 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, humanreadable as well as the syntax in the command. The general syntax is $ rsync optionssourcedestination 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 rsyncworkstuff.sh This will allow all users to execute the script.
CAT out the contents of the rsyncworkstuff.sh script to the screen using the 'cat homeusernamescriptsrsyncworkstuff.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 rsyncwork.sh script information. This will be screenshot # of the assignment.
To have this script execute each day at midnight, we need to either put a copy of this script in the etccrondaily directory or create a crontab entry with the appropriate time specifications or using @daily Copy the homeusernamescriptsrsyncworkstuff.sh script to your etccrondaily directory.
Perform a long listing of the etccrondaily directory. You should see your rsyncworkstuff.sh script with its permissions, owner, etc....
You should still be in your homeusernamescripts directory. If not, go there now.
Add the rsyncworkstuff.sh script to your the root user's crontab. This script should execute at 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 rsyncworkstuff.sh script being ran from your homeusernamescripts directory at minutes past every hour Monday through Saturday. Please use crontab.guru website to check your crontab entry. This will be screenshot # of the assignment.
Wait until minutes past the nearest hour or the next day. Move into your homeusernamebackup directory. There should be an rsyncd copy of the sysdoc.txt file there from either the etccrondaily directory executing the script, or the crontab executing the script at minutes past the hour. Perform a long listing of your homeusernamebackup directory. Capture a screenshot using the "Create Screenshot Package" option in TealVirt showing the rsyncd copy of sysdoc.txt This will be screenshot # of the assignment.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started