Day 5 Task: Advanced Linux Shell Scripting for DevOps Engineers with User management

Tasks

  1. You have to do the same using Shell Script i.e using either Loops or command with start day and end day variables using arguments -

So Write a bash script createDirectories.sh that when the script is executed with three given arguments (one is directory name and second is start number of directories and third is the end number of directories ) it creates specified number of directories with a dynamic directory name.

Example 1: When the script is executed as

./createDirectories.sh day 1 90

then it creates 90 directories as day1 day2 day3 .... day90

Input:

Output:

Example 2: When the script is executed as

./createDirectories.sh Movie 20 50 then it creates 50 directories as Movie20 Movie21 Movie23 ...Movie50

Output:

Using the same input but, giving a different argument.

  1. Create a Script to backup all your work done till now.

    Input :

Output:

Now , We have backed up our Data but if we want to Take a backup every 2 minutes.
We will use Crontab.

So, What is a Crontab ?

It is a job scheduler on Unix-like operating systems.

If you give command : cat /etc/crontab it will give output, this output will help you to understand how the scheduler can be operated.

Output:

Let's use this to take a backup every 2 minutes by adding the Backup Script to Crontab.

Input : added " /2 * . /home/azureuser/shell_folder/takebackup.sh " in crontab

This will run every 2 minutes and store the backup at our mentioned folder in the script.

Output: Every 2 Minutes

  1. Create 2 users and just display their Usernames.

    Input :

here -m : create the user's home directory

Output: to Display created users . Command : cat /etc/passwd

Day 5 Task Complete.

Thank you.