bash scripts
bash scripts
#!/bin/bash
echo "Enter a"
read a
echo "Enter b"
read b
echo "Enter c"
read c
#!bin/bash
add_user()
{
user=$1
password=$2
useradd -m -p $pass $user && echo "User added successfully"
}
#!/bin/bash
src_dir=/home/ec2-user/script
dest_dir=/home/ec2-user/backups
curr_timestamp=$(date "+%Y-%m-%d-%H-%M-%S")
bkp_file=$dest_dir/$curr_timestamp.tgz
#Now bkp_file has string with name /home/ec2-user/backup/timestamp.tgz (zip
format)
echo "Taking backup at time $curr_timestamp"
#now tar command will take files from src_dir and make a zip file with timestamp
name in backup folder
tar czf $bkp_file --absolute-names $src_dir
echo "backup complete"
################################### DiskUtilStorageAlarm
###################################################
#!/bin/bash
#limit=90
df -h | awk '{print $5 " " $1}' | while read output;
do
result=$(echo $output | awk '{print $1}' | cut -d'%' -f1)
disk_name=$(echo $output | awk '{print $2}')
# echo "$disk_name"
# echo "$result"
if [ $result -ge 5 ]
then
echo "Alert $disk_name"
else
echo "limit Not crossed"
fi
done