Skip to content

Instantly share code, notes, and snippets.

View yazanmonshed's full-sized avatar
♟️

Yazan Monshed yazanmonshed

♟️
View GitHub Profile
#!/bin/bash
# GLOBAL VARABILES
PATHFILES=$1
PATHBACKUPS=$2
FILEBACKUP=$3
JOBNAME=$4
DATE=$(date "+%d-%m-%Y-%H-%M-%S")
#!/bin/bash
#Date Dump Database
#DBDATE=$(date "+%b-%d-%Y-%H-%M-%S")
# call by value variables
DBUSER=$1
DBPASS=$2
DBNAME=$3
@yazanmonshed
yazanmonshed / remove-docker-logs.sh
Last active October 16, 2022 21:14
Remove Docker Containers Logs
#!/bin/bash
# dir logs files
PATHLOGS=/var/lib/docker/containers/
## This script is only for remove logs for docker containers
## Please make sure to change permission for file such chmod +x remove-docker-logs.sh
# Vlidate path for docker logs
if [ ! -d $PATHLOGS ]; then
#!/bin/bash
# Notes
# *** need to export GCP Service account insdie the script
# pull data from S3 to local
DIR="/path/to/"
@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
@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 / 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-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 / 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."
#!/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 {} \;