Skip to content

Instantly share code, notes, and snippets.

View yazanmonshed's full-sized avatar
♟️

Yazan Monshed yazanmonshed

♟️
View GitHub Profile
@yazanmonshed
yazanmonshed / upgrade_jenkins.sh
Created May 2, 2024 13:47
Upgrade Jenkins to latest version
#!/bin/bash
## upgrade Jenkins steps
# Stop running Jenkins service
systemctl stop jenkins.service
# Take Jenkins instance Backup as a recovery option
@yazanmonshed
yazanmonshed / update_specific_value_script.sh
Last active November 30, 2023 08:39
searching & update specific values in
#!/bin/bash
if [ -z "$1" ]; then
echo "Error: Please provide a value."
exit 1
fi
sed -i "s/OLD_VALUE.*/NEW_VALUE='$1'/" /path_the_files/file_name.yml
echo "NEW_VALUE updated to '$1' in file_name.yml file."
servers_ips=`aws ec2 describe-instances --region us-east-1 --filters "Name=tag-value,Values=TAG_NAME" "Name=instance-state-name,Values=running" --query 'Reservations[].Instances[].[PrivateIpAddress]' --output text | xargs`
echo $cs_server
# Pass by IP's to tmux-cssh script
./tmux-cssh $cs_serve
#!/bin/bash
# Set the path to the Laravel logs directory
LOG_DIR=/path/to/laravel/logs
# Set the number of days to keep log files
DAYS_TO_KEEP=7
# Find all Laravel log files older than $DAYS_TO_KEEP days and delete them
find "$LOG_DIR" -name "*.log" -type f -mtime +$DAYS_TO_KEEP -exec rm {} \;
@yazanmonshed
yazanmonshed / check_installed_packages.sh
Last active May 5, 2024 09:10
check the installed package on system (Debian Based OS)
#!/bin/bash
# Pass the package name
package=$1
# Check if the package is installed on system ()
if dpkg -s $package > /dev/null 2>&1; then
echo "$package is installed."
else
echo "$package is not installed."
@yazanmonshed
yazanmonshed / check-remote-ports.sh
Last active January 17, 2023 10:49
Check remote ports from Jenkins Bypassing the IP & Port
#!/bin/bash
# Set the server address and port number, Ex (Pass by Jenkins as a parameter’s)
server=$1
port=$2
# Check if the port is open
nc -v -z $server $port
if [ $? -eq 0 ]; then
@yazanmonshed
yazanmonshed / display-top-processes.sh
Created January 17, 2023 10:34
Display top processes in system
#!/bin/bash
# Display the top 10 processes by memory usage
ps aux --sort=-%mem | head -n 11
@yazanmonshed
yazanmonshed / check-desk-space-usage.sh
Created January 17, 2023 10:32
Script for check desk space usage
#!/bin/bash
# Set the threshold for disk space usage (in percent)
threshold=90
# Get the current disk space usage
usage=$(df / | awk '{ print $5 }' | tail -n 1 | sed 's/%//')
# Check if the usage is above the threshold
if [ $usage -gt $threshold ]; then
@yazanmonshed
yazanmonshed / check-status-service.sh
Created January 17, 2023 10:27
Check status service using Bash script with Jenkins
#!/bin/bash
# Check the status of the service
# Pass as param from Jenkins Server
service=$1
if systemctl is-active --quiet $service; then
echo "$service is running."
else
echo "$service is not running."
fi
#!/bin/bash
# Notes
# *** need to export GCP Service account insdie the script
# pull data from S3 to local
DIR="/path/to/"