first commit

This commit is contained in:
Roy
2025-06-23 21:19:51 +02:00
commit a4f9ea11f3
69 changed files with 4857 additions and 0 deletions

13
ssh_loops/loop_array.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
#find only derctoris older then 10 days
DIR_NAME=($(find /opt/backup/database/ -maxdepth 1 -type d -ctime +10))
for dir in "${DIR_NAME[@]}"
do
echo "tar -cvPf $dir.tgz $dir --remove-files"
done
#this will tar and remove
#tar -cvf /home/roy/Desktop/test/some_dir.tgz /home/roy/Desktop/test/some_dir --remove-files

View File

@ -0,0 +1,51 @@
#!/bin/bash
#find only directories older then 10 days
#this will tar and remove
#tar -cvf /home/roy/Desktop/test/some_dir.tgz /home/roy/Desktop/test/some_dir --remove-files
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "$package - attempt to capture frames"
echo " "
echo "$package [options] application [arguments]"
echo " "
echo "options:"
echo "-h, --help show brief help"
echo "--days=<1-n> specify an action to use"
echo "-o, --output-dir=DIR specify a directory to store output in"
exit 0
;;
-a)
shift
DIR_NAME=($(find /var/log -maxdepth 1 -type d -mtime +10))
if test $# -gt 0; then
export PROCESS=$1
else
for dir in "${DIR_NAME[@]}"
do
echo "tar -czPf $dir.tar.gz $dir --remove-files"
done
exit 1
fi
shift
;;
--days*)
DIR_NAME=($(find /var/log/ -maxdepth 1 -type d -mtime +$2))
if test $# -gt 0; then
export PROCESS=$1
else
for dir in "${DIR_NAME[@]}"
do
echo "tar -czPf $dir.tar.gz $dir --remove-files"
done
exit 1
shift
;;
*)
break
;;
esac
done

View File

@ -0,0 +1,18 @@
#!/bin/bash
# This script will check the runing services for every host you provide in a source file.
# Example of running ./service_check_loop.sh <some_file_with_hosts>
HOSTNAME=($(cat $1))
if [ $# -lt 1 ]
then
echo "Syntax: ./$(basename $0) <file name>"
exit
fi
for host in "${HOSTNAME[@]}"
do
printf "%s " "$host,"
SSH_OUT=$(ssh -n root@$host "netstat -pnltu|cut -d "/" -f2|sed '/^$/d'|sort|uniq"|tr '\n' ',')
echo $SSH_OUT
done |tee -a /tmp/$1.log