0% found this document useful (0 votes)
3 views

Lab 16_ Shell Scripting and Automation

This document outlines Lab 16, focusing on shell scripting and automation skills. Participants learn to create basic shell scripts, assign execute permissions, schedule tasks using crontab, and automate system updates and monitoring. These skills are crucial for system administrators and DevOps engineers to enhance efficiency and system reliability.

Uploaded by

sodayac916
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab 16_ Shell Scripting and Automation

This document outlines Lab 16, focusing on shell scripting and automation skills. Participants learn to create basic shell scripts, assign execute permissions, schedule tasks using crontab, and automate system updates and monitoring. These skills are crucial for system administrators and DevOps engineers to enhance efficiency and system reliability.

Uploaded by

sodayac916
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

This document is the property of Al Nafi.

Any unauthorized redistribution or reproduction, including in printed form, is strictly


prohibited. This document can only be read electronically.

Lab 16: Shell Scripting and Automation

Objective:
The objective of this lab is to acquire skills in automating tasks through shell scripting.

td
Detailed Steps:

tl
1. Write a Basic Shell Script:

Pv
● Use a text editor such as nano or vim to create a shell script file with a .sh
extension.

ng
nano backup_script.sh
ni
● Write a basic shell script to perform a task such as backing up files. For example:
ar
Le

#!/bin/bash

# Backup script
tar -czvf backup.tar.gz /path/to/files
IE

2. Assign Execute Permission to the Script:


AF

● Use the chmod command to give execute permission to the script.


N

chmod +x backup_script.sh
AL

3. Schedule Tasks Using Crontab:


● Use the crontab -e command to edit the cron table and schedule tasks.

crontab -e
● Add an entry to the crontab file to schedule the execution of the shell script at a
specified time or interval.

# Example: Run the backup_script.sh every day at midnight


0 0 * * * /path/to/backup_script.sh

td
tl
4. Automate System Updates and Monitoring Scripts:

Pv
● Write shell scripts to automate system updates and monitoring tasks.
● For system updates, use package management commands like apt update and
apt upgrade for Debian-based systems or yum update for Red Hat-based

ng
systems.
● For system monitoring, use tools like top, df, free, and custom monitoring
ni
scripts to gather system metrics and log information.
ar
Conclusion:
Le

This lab has provided hands-on experience in shell scripting and automation.
Participants have learned how to write basic shell scripts to automate tasks, assign
execute permissions to scripts, schedule tasks using cron, and automate system
IE

updates and monitoring scripts. These skills are essential for system administrators
and DevOps engineers to streamline repetitive tasks, improve efficiency, and ensure
AF

system reliability.
N
AL

You might also like