Posts

Showing posts from 2015

Enable TUN/TAP and PPD in VM on open VZ

How to enable TUN/TAP and PPD in VM on open VZ = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Please use the below steps to Enable TUN/TAP and PPD in VM on open VZ.    1.Check the Node is enabled with tun/tap by entering the same from solusVM.    >> Go to list node >> edit node >> check "Allow clients to set TUN/TAP" and "Allow clients to set PPP".        2.How to enable TUN/TAP in OpenVZ? ========================================================================================     +++++++++++++++++++++++++++++++++++++++++++++ STEP 1: Login to Node via SSH STEP 2: Run the below pasted command to find out tun module is already loaded or not [root@Node]# lsmod | grep tun [root@Node]#      If the output of the above commands returns a blank value means the tun module is not loaded in your Node. Run the below command to load tum module. [root@Node]# modprobe tun [root@Node]# lsmod | grep tun tun    82432  

MySql database backup shell script

#!/bin/sh # Setting date to name the backupfile with todays date date=`/bin/date "+%Y%m%d"` # creating backup folder /bin/mkdir -p /mysqlbkp/dbbackup_$date DBS="$(mysql -Bse 'show databases')" for db in $DBS do /usr/bin/mysqldump --routines $db > /mysqlbkp/dbbackup_$date/ $db.sql done The backups will be generated in the location /mysqlbkp under the folder dbbackup_todays date.

Simple Shell Script for Disk Space Notification

1. Create a file /home/diskspace.sh 2. Enter the following code in the script ============================= #!/bin/sh #Threshold is set to 70 here. THRESHOLD=70 MAILTO=”youremailaddress” TEMPFILE=/tmp/diskspace.temp HOSTNAME=`hostname` rm -f $TEMPFILE #Calculate the Current Disk Usage with the below command. CDU=$(df -h | tail -1 | awk ‘{print $5}’ | sed ‘s/%//’) #Compare the current value with the threshold one. if [ $(expr $CDU ">=" $THRESHOLD) -ne 0 ] then echo “Warning!!! Disk Space usage on server $HOSTNAME is ${CDU}%” >> $TEMPFILE fi #Send an email if /tmp/diskspace.temp is present. if [ -e $TEMPFILE ] then mail -s “Disk Space Notification” $MAILTO < $TEMPFILE fi rm -f $TEMPFILE ============================== 3. Save the file and execute using crontab crontab -e 0 1 * * 0  /bin/sh  /home/diskspace.sh

Process uptime - Linux

How to find the uptime of a Linux Process ----------------------------------------------------- 1. Login to the server as root. 2. Run the below provided command ps -eo pid,comm,lstart,etime,time,args | grep process-name Acronyms PID - Process ID .ie. the ID of the process that we are searching. comm - Display the process name. lstart - The time at which the process is started. etime - The time elapsed once the process is started. args - command with options and arguments. process-name - The process for which we need to check uptime. For eg : :~$ ps -eo pid,comm,lstart,etime,time,args | grep cron   937 cron            Fri Jan 30 09:42:17 2015       37:36 00:00:00 cron The cron deamon is running in the server from 9:42 AM and is alive for 37 minutes till now. Check the etime field. (37:36) This is how we can detect the uptime of a process in Linux. Added on Jan 30 10.26 AM