Day-06 shell scripting
-> Multi-functions
-> Log Rotation Scripts.
-> Development Environment use case script by using functions.
1) Function: A function is a block of code that can be called whenever needed. It allows for code reuse and better organization.
Example in Python
def addition (a, b): # Passing two parameters: a and b
return a + b # Returns the sum of a and b
#Calling the function
result_a = addition (2, 3)
#Running the scripts to delete or checking unused instances in development Environment with certain period.
#Explanation:
Why we are running this script because we need to know the status of how many unused instances are there in development Environment.
then after retrieving the information from below script then we can delete instances after manager approval.
For testing purposes, I have set the time period to 5 minutes to quickly identify any unused EC2 instances. However, you may choose a different time period that suits your requirements.
crontabs:
which are used to schedule tasks to run at specific intervals on Unix-like operating systems.
crontab -e # Edit the crontab file
# Add the following line:
* * * * * sudo bash /root/example.sh us-east-1 # Adjust timing as needed
Ensure that your script is saved at /root/example.sh.