23May/100
How To Update all CentOS/RHEL servers remotely using a shell script
#!/bin/bash
#
# A simply shell script to update remote CentOS/RHEL servers
# You must have ssh public and private key installed. This will save a lot of time if you
# have many servers.
#
# by Adi https://blog.up-link.ro
# May 2010
# an array to store ssh commands for each server
hosts=(
        "ssh root@192.168.1.1 yum update -y"
        "ssh root@192.168.2.1 -p 2222 yum update -y"
        "ssh adi@192.168.3.1 -t sudo  '/usr/bin/yum update -y'"
      )
# read the array and launch the ssh command
for sshcmd in "${hosts[@]}";do $sshcmd;done
 Print This Post
 Print This Post
3May/100
Unix-like Tips and Tricks: BASH Redirection
Bash is a POSIX shell with a number of extensions. It is the shell for the GNU operating system from the GNU Project. It can be run on most Unix-like operating systems.
In this article I'll talk about bash redirections.
 Print This Post
 Print This Post
30Mar/100
How To Backup MySQL databases using a shell script
MySQL is one of the most popular open source database management system for the development of interactive websites.
If your server stores its sensitive data in a MySQL database, you will most definitely want to backup that information so that it can be restored in case of any disaster.
Below is a backup script for MySQL databases (please make sure you will change MYSQL_PASS):
#!/bin/sh # backup mysql databases shell script # UNIX LINUX BSD # by Adi https://blog.up-link.ro # March 2010 DATE=$(date +%Y-%m-%d) MYSQL=$(which mysql) MYSQLDUMP=$(which mysqldump) MYSQL_USER="root" MYSQL_PASS="password" HOSTNAME=$(hostname) GZIP=$(which gzip) ARG="-u $MYSQL_USER -p$MYSQL_PASS" DATABASES=$($MYSQL $ARG -s -e "SHOW DATABASES;") BACKUP_PATH="/home/backup/$DATE/mysql" ! [ -d $BACKUP_PATH ] && mkdir -p $BACKUP_PATH for DB in $DATABASES do BACKUP_FILE="$BACKUP_PATH/$HOSTNAME-mysql-$DB-$DATE.sql.gz" $MYSQLDUMP $ARG $DB | $GZIP -9 > $BACKUP_FILE done
Download the script from here.
 Print This Post
 Print This Post
 Loading ...
 Loading ...