In the second week, I focused on writing more advanced scripts to handle real-world system administration and automation tasks.
1. File & Directory Management
Automated file creation, modification, and deletion.
Worked with file permissions and ownership.
2. Process & Job Control
Learned how to manage background and foreground processes.
Used commands like
ps
,kill
, andnohup
to handle system tasks.
3. Networking & System Monitoring Scripts
Created scripts to check server health and uptime.
Automated network diagnostics using
ping
andnetstat
.
4. Advanced Shell Scripting Techniques
Used
awk
andsed
for text processing.Learned about regular expressions for better pattern matching.
Scheduled tasks using cron jobs.
5. Final Hands-on Project: Automating AWS Resource Monitoring
To wrap up the challenge, I improved my AWS script by adding logging and automation features.
New Features Added:
Script now logs AWS service availability into a file.
#!/bin/bash ##################################################### ## Author : Parthasarathy G ## Version : v1.0 ## Description : Email sending accoriding aws services availability and unavailability ##################################################### AWS_SERVICES=("ec2" "s3" "rds") TO_EMAIL="your_email@example.com" SUBJECT="AWS Service Availability Alert" LOG_FILE="/var/log/aws_service_monitor.log" check_aws_service() { local service=$1 if aws $service describe-instances &> /dev/null; then echo "$(date): AWS $service is available." >> "$LOG_FILE" else echo "$(date): AWS $service is unavailable!" | tee -a "$LOG_FILE" | mail -s "$SUBJECT" "$TO_EMAIL" fi } for service in "${AWS_SERVICES[@]}"; do check_aws_service "$service" done
Sends email notifications when specific services are down.
#!/bin/bash
#####################################################
## Author : Parthasarathy G
## Version : v1.0
## Description : Email sending when services down
#####################################################
SERVICES=("nginx" "mysql" "apache2")
TO_EMAIL="123456789helloworld@example.com"
SUBJECT="Service Down Alert"
check_service() {
local service=$1
if ! systemctl is-active --quiet "$service"; then
echo "Service $service is down!" | mail -s "$SUBJECT" "$TO_EMAIL"
fi
}
for service in "${SERVICES[@]}"; do
check_service "$service"
done
What I Gained from This Project:
Understood the importance of logging and monitoring.
Learned how to integrate shell scripts with cloud services.
Got comfortable with automation techniques for real-world applications.
Final Thoughts
These two weeks have been an exciting learning experience. Shell scripting has proven to be a valuable skill, helping me automate repetitive tasks and improve my overall workflow. The ability to write efficient scripts not only saves time but also helps in managing system resources effectively.
If you're thinking about learning shell scripting, I’d definitely recommend starting with small projects and gradually working your way up to more complex automation tasks. It’s a skill that’s both practical and rewarding!
I’ll continue refining my scripts and exploring more advanced concepts. Stay tuned for more updates!