CSC8512 Assignment 2: System Scheduling and File Management

Verified

Added on  2025/05/01

|16
|2826
|342
AI Summary
Desklib provides solved assignments and past papers to help students succeed.
Document Page
CSC8512
ASSIGNMENT 2
Student ID:
Student Name:
1
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Table of Contents
Question 1..................................................................................................................................1
Cron........................................................................................................................................1
Anacron..................................................................................................................................1
Systemd Timers......................................................................................................................1
Question 2..................................................................................................................................4
a).............................................................................................................................................4
b)............................................................................................................................................4
c).............................................................................................................................................4
d)............................................................................................................................................5
Question 3..................................................................................................................................6
a).............................................................................................................................................6
b)............................................................................................................................................7
c).............................................................................................................................................7
Question 4..................................................................................................................................8
References................................................................................................................................10
2
Document Page
Question 1
Cron
For the execution of commands on pre-decided schedule, a tool is used which is cron
daemon. It runs when the system is started and keeps on running until the system stops. The
files which are to be configured are read by the cron which consists of several command lines
& the timing at which they will get invoked. Anything that is possible by the use of hand
from the shell can be done with the cron also as the “sh” executed the command lines.
The efficiency of the cron is fully maintained by the crontab as it helps with the information
of the crontab changing to the cron. Syslog is one of many other advantages of cron.
Every crontab has a similar format in the system. In the very first section of a line, comments
are entered with a pound sign (#). There are six fields for each line with no comment and 1
command. When to run the command, the first five fields tell cron. They are segregated by
white space, but white space is transferred to the shell inside the filed command.
Field Description Range
Minute Hour’s Minute 0 59
Hr Day’s hour 0 23
Dom Month’s day 1 31
Month Year’s month 1 12
Weekday Week’s day 0 6 where Sunday is 0
Anacron
Anacron is a regular command program which is performed by cron. It is basically a
program. The system does not run continuously. Hence, controlling the execution of the
monthly, weekly and daily jobs which are not running for 24 hrs per day, the anacrons can be
used. Most Linux systems use monthly, weekly & daily scripts to manage several '
housekeeping tasks ' including logging etc. For all the laptop users as well as for those who
use a computer, anacrons are suggested. Tasks should be performed with cron once the
system is not in operation. If the system is really off, the task will not run. Anacron is unique
and moves tasks at different times so that when the system is on, cron is used.
3
Document Page
Anacron has its own disadvantages as it allows the task to execute only for a day or a week or
a month. Cron enables tasks to be run every minute, however. Only one anacron task runs at a
time when the system restarts at midnight then the everyday tasks are executed after just a
user delay. The next one begins when it is finished.
Systemd Timers
The unit files in a system which have .tmer in the end and are able to control various files &
events such as .service files. Calendar time activities, repetitive time activities are supported
by Timers and can be run dynamically. Timers are like other unit settings files and are
stacked from a certain path but contain a section called Timer. The timer section identifies
when the timer is turned on and how it was activated. These are described as two different
types:
Monotonic Timers Activates relative to a different starting point after a particular time
span.
Real-time Timers Activation at the calendar activity time.
There are various characteristics of these timers:
Jobs that make debugging simpler can easily start from their times.
Each job could be set up to run in a particular environment.
Jobs can also be created to rely on certain systemd units.
Jobs for easy debugging are logged into the systemd journal.
4
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
There are several disadvantages of these timers when compared with the cron ones.
Complexity Factor For setting up a job which is timed with the
use of system timers one needs to create 2
files & also have to execute a few systemctl
commands. Whereas in the cron only a
single line is added to the crontab.
Emailing Factor Cron’s mailto i.e. even if the unit fails the
email will be sent is the best and has no
built-in equal competition.
Cron configuration for running daily, weekly and monthly for date commands
The instruction used for editing cron jobs is crontab –e
0 0 * * * date >> desktop/student_Work1/result-time.txt Date output is stored daily in a
result-time.txt format
0 0 * * * 0 date >> desktop/student_Work1/result-time.txt the output command is stored
weekly to the result-time.txt file
0 0 1 * * *date >> desktop/student_Work1/result-time.txt in the result-time.txt monthly
output date is saved.
The command is cut into six different parts which are discussed in the cron part in the
starting.
All five quantitative fields must be individually recognized and part six gives the command to
be carried out. Throughout this /desktop / student_Work1/result-time.txt file the information
output is collected.
<<Appropriate-screenshots-here>>
5
Document Page
Anacron configuration for running daily, weekly and monthly for date commands
@daily_date date >> /desktop/student_Work1/result-time.txt fifteen minutes delay in the
anacron running daily
@weekly_date date >> /desktop/student_Work1/result-time.txt fifteen minutes delay in
the anacron running weekly
@monthly_date date >> /desktop/student_Work1/result-time.txt fifteen minutes delay in
the anacron running monthly
The primary (first) field of anacron denotes the period of repetition.
The 2nd area in anacron configuration indicates the lag in job performance after the
device has begun working. The value is daily, weekly or monthly. Value 15 means
that the system must be held for 15 minutes before starting the execution process.
The 3rd field is the time stamp file for work. All work performance details are
recorded in the file in /var //spool / anacron
<<Appropriate-screenshots-here>>
Systemd configuration for running daily, weekly and monthly for date commands
Formation of the timedata.service
Alteration of the file /etc/systemd/system/timedata.service & add this below line:
Prints date into /desktop/student_Work1/result-time.txt
Execute Start /usr/bin/sh -c '/usr/bin/date >>/desktop/student_Work1/result-
time.txt
Formation of timedata.timer
Alter file /etc/systemd/system/timedata.timer
Running timedata.service daily
OnCalendar *-*-* 00:00:00
Use systemctl to start timedata.timer. Now the timer will start.
The On Calendar value is set by weekly time
In order to set the timer to carry out the service in monthly order, the explanation and
On calendar value should be set.
6
Document Page
<<Appropriate-screenshots-here>>
Question 2
a)
In this format the name of the file should be presented, i.e. date.tgz. To offer the precise file
name, the dates command is used. The date and time of the current system are printed on the
Linux systems with the command "date." The following are more useful options:
To get the desired file name, the variable file_name=$(date + "% Y % m % d% H % M") is
set. Using the touch $ file_name command, the file is generated after variable creation. Use
the instruction ls -l to view the generated file.
<<Appropriate-screenshots-here>>
b)
To delete files older than 30 days, find -mtime + 30 -exec rm { } \
To search for files older than 30 days, use the argument –mtime + 30 \
exec rm { } to delete the file.
For closing the command “/” is used.
Command –print is being used to print file names over 30 days.
The sudofind instruction is used to print those files older than 30 days which are
ending with.txt –Type f – iname "* .txt" –mtime + 30 –print and is used to print all
files that end with.txt and are over 30 days old.
<<Appropriate-screenshots-here>>
c)
The rsync -avh command —delete ~$filename together with rysnc is being used to take a
gradual backup from home directory.
7
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
For archive mode, the added option is –a
To exhibit verbose output, the choice is –v
To exhibit algebraic expressions readable by humans, the choice is –h
To delete files, the delete alternative is added to delete all files in the origin directory
as rsync may not delete every other by default values.
<<Appropriate-screenshots-here>>
File_name $(date +"%Y%m%d%H%M")
<<Appropriate-screenshots-here>>
Taking present user backup successfully.
<<Appropriate-screenshots-here>>
Forming file new file.txt in the home directory of the present user.
<<Appropriate-screenshots-here>>
Rsync was executed again and the gradual file was upgraded, but this time the main backup
may not have been taken.
<<Appropriate-screenshots-here>>
d)
The user implements the following script to back up a home directory
File_name=$(date +"%Y%%m%%d%H%M") assigning present date & time in the
required format
<<Appropriate-screenshots-here>>
rsync –avh –delete ~$file_name The present user home directory is backed up using rsync
and the present date and time is recorded in the required folder.
<<Appropriate-screenshots-here>>
tar –zcvf $file_name.tgz $file_name compression of the folder is required
<<Appropriate-screenshots-here>>
rm –R $file_name removing the folder / not needed anymore
8
Document Page
<<Appropriate-screenshots-here>>
find . –type f –iname “*tgz” -mtime +30 -exec rm {} Scanning the current directory for
the .tgz file that is 30 days older & finally removing the file.
9
Document Page
Question 3
a)
SSH Source Shell. It uses cryptographic verification to verify the identity of a user and
encrypt all the communication between the hosts. The SSH-protocol is intended to resist
various potential attacks. The protocol is used. SSH has become a commercial product with a
slightly different SSH2 protocol, from a freely distributed open source i.e. SSH1. The
OpenSSH package, which currently enforces both protocols, is now released by OpenSSH
community.
The SSH has some major components namely sshd, server daemon & various user-level
commands. SSH remote logins & SFTP or SCP copying files. The ssh-keygen
command which generates public key sets and many utilities that help secure Windows other
components. Various methods are as follows:
Method-A
This method reflects the old login daemon, which we think cannot be used normally.
The sshd logs in an sshd user without checking the password automatically when the
remote host name from which the users log in is ~/.rhosts,~/.shosts,/etc / hosts.equiv.
Method-B
The public host remote host should be listed in /etc / ssh knownhostsfile or in the
~/.ssh.knownhostsfiles of the local host to verify the identification of the remote host
using public key encryption.
Method-C
The user has to access and provide a password to decrypt a copy of his private key file
at login time. The password for automating logins from remote systems is also
available without the key. The configuration is secure, but annoying. If a user wants
to use key pairs, use ssh-v extensively during performance monitoring.
Method-D
This is very similar to telnet, except that both session & password is encrypted.
Having failed to improve your security, ready-made techniques have made it possible
10
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
to break system connection passwords comparatively weak. Probably the best way to
use this technique is for ordinary use.
11
Document Page
b)
~/.ssh/knownhosts includes a program-wide list of possible host keys to confirm the remote
host identity and hence prevent impersonation. The system manager should start preparing
this file to contain and read the public network keys of all hosts needed. This file contains
recognized keys for which the remote host was already connected and then used to confirm
its identity and to protect against impersonation or human attacks throughout the middle. The
key is equated to the key offered by the remote server with every successive connection. The
connection proceeds if there is a match. SSH will fail with an error message if match fails. If
the key is not listed, the fingerprint of the key will be shown, and a key can be added into the
file automatically. The above file can indeed be developed and manually edited, but if it isn't
available, this can be automatically created by SSH when connecting to a remote host first.
c)
The user can increase the confidence among two Linux servers by using a password-less
authentication with SSH keys for simple file syncing or shift. This is among the best ways to
automate such tasks as auto script backups, SCP sync and remote unit execution. Some steps
must be taken for this purpose which are as follows:
1. $ssh –keygen –t rsa
Once this command has been entered, the program will ask the manager to enter the
pass-phrase to secure the private key. The system indicates the path to which the
identification is processed if the passphrase matches.
2. $ sshabcmkdir –p .ss
This function requires users to create a key that is private on their system. Once you
type yes the IP address of this system is added to the server permanently when you
enter your password.
3. $ cat .ssh/name.pub | sshabc ‘cat’ >>.ssh/keyauthorized
This instruction adds the user system's public key. The system will request the user to
type the password of the user once the instruction has been entered. The user then
receives the public key.
4. $ sshabc ‘chmod 700 .ssh ;chmod 640 .ssh/keyauthorized’
12
chevron_up_icon
1 out of 16
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]