Shell script to backup MySql database July 31st, 2009
#!/bin/bash
# Shell script to backup MySql database
# To backup Nysql databases file to /backup dir and later pick up by your
# script. You can skip few databases from backup too.
# For more info please see (Installation info):
# http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/01/mysql-backup-script.html
# Last updated: Aug – 2005
# ——————————————————————–
# This is a free shell script under GNU GPL version 2.0 or above
# Copyright (C) 2004, 2005 nixCraft project
# Feedback/comment/suggestions : http://cyberciti.biz/fb/
# ————————————————————————-
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ————————————————————————-
Â
MyUSER=“SET-MYSQL-USER-NAME”    # USERNAME
MyPASS=“SET-PASSWORD”      # PASSWORD
MyHOST=“localhost”         # Hostname Read the rest of this entry »
Shell script to get uptime, disk usage, cpu usage, RAM usage, system load, etc; from multiple Linux servers and output the information on a single server in html format
#!/bin/bash # Shell script to get uptime, disk usage, cpu usage, RAM usage,system load,etc. # from multiple Linux servers and output the information on a single server # in html format. Read below for usage/installation info # *---------------------------------------------------------------------------* # * dig_remote_linux_server_information.bash,v0.1, last updated on 25-Jul-2005* # * Copyright (c) 2005 nixCraft project * # * Comment/bugs: http://cyberciti.biz/fb/ * # * Ref url: http://cyberciti.biz/nixcraft/forum/viewtopic.php?t=97 * # * This script is licensed under GNU GPL version 2.0 or above * # *---------------------------------------------------------------------------* # * Installation Info * # ----------------------------------------------------------------------------* # You need to setup ssh-keys to avoid password prompt, see url how-to setup # ssh-keys: # cyberciti.biz/nixcraft/vivek/blogger/2004/05/ssh-public-key-based-authentication.html # # [1] You need to setup correct VARIABLES script: # # (a) Change Q_HOST to query your host to get information # Q_HOST="192.168.1.2 127.0.0.1 192.168.1.2" # # (b) Setup USR, who is used to connect via ssh and already setup to connect # via ssh-keys # USR="nixcraft" # # (c)Show warning if server load average is below the limit for last 5 minute. # setup LOAD_WARN as per your need, default is 5.0 # # LOAD_WARN=5.0 # # (d) Setup your network title using MYNETINFO # MYNETINFO="My Network Info" # # (e) Save the file # # Please refer to forum topic on this script: # Also download the .gif files and put them in your output dir # # ---------------------------------------------------------------------------- # Execute script as follows (and copy .gif file in this dir) : # this.script.name > /var/www/html/info.html # ============================================================================ # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ------------------------------------------------------------------------- Â # SSH SERVER HOST IPS, setup me # Change this to query your host Q_HOST="192.168.1.2 127.0.0.1 192.168.1.2" Read the rest of this entry »
Monitor UNIX / Linux Server Disk Space with Shell Script July 31st, 2009
Shell script to monitor or watch the disk space and send an email alert if the (free avilable) percentage of space is >= 90%
#!/bin/sh # Shell script to monitor or watch the disk space # It will send an email to $ADMIN, if the (free avilable) percentage # of space is >= 90% # ------------------------------------------------------------------------- # Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ---------------------------------------------------------------------- # Linux shell script to watch disk space (should work on other UNIX oses ) # SEE URL: http://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html # set admin email so that you can get email ADMIN="me@somewher.com" Read the rest of this entry »
Here is a simple shell script tested on CentOS / RHEL / Fedora / Debian / Ubuntu Linux. Should work under any other UNIX liker operating system. It will check for httpd pid using pgrep command
pgrep command
pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to screen. If no process found it will simply return exit status 0 (zero).
Download the script and set cronjob as follows:
*/5 * * * * /path/to/script.sh >/dev/null 2>&1
Sample script
#!/bin/bash # Apache Process Monitor # Restart Apache Web Server When It Goes Down # ------------------------------------------------------------------------- # Copyright (c) 2003 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ------------------------------------------------------------------------- # RHEL / CentOS / Fedora Linux restart command RESTART="/sbin/service httpd restart" Â # uncomment if you are using Debian / Ubuntu Linux #RESTART="/etc/init.d/apache2 restart" Â #path to pgrep command PGREP="/usr/bin/pgrep" Â # Httpd daemon name, # Under RHEL/CentOS/Fedora it is httpd # Under Debian 4.x it is apache2 HTTPD="httpd" Â # find httpd pid $PGREP ${HTTPD} Â if [ $? -ne 0 ] # if apache not running then # restart apache $RESTART fi
##############eof###############
source here
Shell Script To Encrypt Any Text File July 31st, 2009
In cryptography, encryption is the process of transforming information (referred to as plaintext) using an algorithm (called cipher) to make it unreadable to anyone except those possessing special knowledge, usually referred to as a key.
Mcrypt is a simple crypting program, a replacement for the old unix crypt(1). When encrypting or decrypting a file, a new file is created with the extension .nc and mode 0600. The new file keeps the modification date of the original. The original file may be deleted by specifying the -u parameter. If no files are specified, the standard input is encrypted to the standard output.
Sample Shell Script Wrapper To Encrypt Any Text File
#!/bin/bash Read the rest of this entry »
