Day6: Advanced Linux Shell Scripting for DevOps Engineers.

Day6: Advanced Linux Shell Scripting for DevOps Engineers.

ยท

2 min read

Table of contents

No heading

No headings in the article.

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

    here $1 = day ,$2=start number ,$3= end number.

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

    Taking backups of scripts or whatever functions we have written till now is an essential part of our DevOps journey.

    following the shell scripts are written to back up the source file and stored into the target file in .tgz form which size is smaller than the zip file.

3.Cron and Crontab:

Cron is a time-based job scheduler in Unix-like systems. It allows users to schedule jobs (commands or scripts) to run periodically.

Crontab is a file that contains a list of cron jobs. It is a text file that is typically located in the /etc/cron.d/ directory for system-wide jobs or in the .crontab directory in the user's home directory for user-specific jobs.

Purpose of using cron and crontab in scripts:

Cron and crontab can be used to automate a wide variety of tasks, such as:

  • Backing up files and databases

  • Running system maintenance tasks

  • Sending email notifications

  • Generating reports

  • Processing data

  • Deploying software updates

let's store backup every 2 minutes using cron.crontab of previous scripts.

here */2 is used so that the cron job will run the bash command every 2 minutes.

You can also visit that website for generating code based on the cron tab :- crontab.guru

Overall, cron and crontab are powerful tools for automating tasks in Unix-like systems. They can be used to simplify system administration and improve the efficiency of workflows.

see you on Day 7.....๐Ÿ˜Š!!!!!

ย