How to redirect your site using html or php

It´s been around in thousands of blogs already but i decided to share you this one too.

For HTML

<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/index.html">

Note that “0″ – is in seconds, how fast your site will be redirected.

For PHP

<?php

  header( 'Location: http://www.yoursite.com/new_page.html' ) ;

?>

Note that this will not work if you have html tags before that.

A simple backup script using lftp.

First we have to install package called lftp, as it is not
installed default by any distros out there (as far as i know).

Next we will simply create a file called lftp.scp, which will contain something like this:

lftp -u user,password ftphost -e "mirror --verbose --reverse /localdirectory /remotedirectory" &

Now you need to simply the following command

lftp -f lftp.scp
As for me i use this command with a crontab every midnight

0 0 * * * lftp -f /path/to/lftp.scp >/dev/null 2>&1

Bash Script to kill Zombie proccesses.

This script below will find all the zombie processes and kill them.
It will ask you to prompt y/n if found any.


#! /bin/bash
#
# Zombie processes killing script. Must be run under root.

case "$1" in --admin)
        stat=`ps ax | awk '{print $1}' | grep -v "PID" | xargs -n 1 ps lOp | grep -v "UID" | awk '{print"pid: "$3" *** parent_pid: "$4" *** status: "$10" *** process: "$13}' | grep ": Z"`

        if ((${#stat} > 0));then
            echo zombie processes found:
            echo .
            ps ax | awk '{print $1}' | grep -v "PID" | xargs -n 1 ps lOp | grep -v "UID" | awk '{print"pid: "$3" *** parent_pid: "$4" *** status: "$10" *** process: "$13}' | grep ": Z"
            echo -n "Kill zombies? [y/n]: "
            read keyb
            if [ $keyb == 'y' ];then
                echo killing zombies..
                ps ax | awk '{print $1}' | grep -v "PID" | xargs -n 1 ps lOp | grep -v "UID" | awk '{print$4" status:"$10}' | grep "status:Z" | awk '{print $1}' | xargs -n 1 kill -9
            fi
        else
            echo no zombies found!
        fi
;;
--cron)
        stat=`ps ax | awk '{print $1}' | grep -v "PID" | xargs -n 1 ps lOp | grep -v "UID" | awk '{print"pid: "$3" *** parent_pid: "$4" *** status: "$10" *** process: "$13}' | grep ": Z"`
        if ((${#stat} > 0));then
        ps ax | awk '{print $1}' | grep -v "PID" | xargs -n 1 ps lOp | grep -v "UID" | awk '{print$4" status:"$10}' | grep "status:Z" | awk '{print $1}' | xargs -n 1 kill -9
        echo `date`": killed some zombie processes!" >> /var/log/zombies.log
        fi
;;
*)      echo 'usage: kill-zombies {--cron|--admin}'
;;
esac
exit 0

You will need to give this script executable rights.
Usage of the script is ./scriptname.sh –cron / –admin