jenkins -- bigbucket - git - apache-tomcat -- sonar intergration doc





step 1


Installation of jenkins :  ( with out  apache tomcat , stand alone instance )
( this steps are done on test machine )


yum install java-1.6.0-openjdk
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
Sudo yum install jenkins





All config details :
/etc/sysconfig/jenkins
/var/lib/jenkins/



Installation of jenkins :  ( with   apache tomcat. Tomcat will inturn run the jeninks.war file  )


( these steps are done on Actual machine ) 



    Step 1: Install the JDK\




[root@station1 Downloads]# rpm -ivh jdk-7u7-linux-x64.rpm
[root@station1 Downloads]# JAVA_HOME=/usr/java/jdk1.7.0_
07
[root@station1 Downloads]# export JAVA_HOME
[root@station1 Downloads]# PATH=$JAVA_HOME/bin:$PATH
[root@station1 Downloads]# export PATH
[root@station1 Downloads]# vim /root/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
       . ~/.bashrc
fi

# User specific environment and startup programs
JAVA_HOME=/usr/java/jdk1.7.0_07/
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
#PATH=$PATH:$HOME/bin
#export PATH
Restart or logout and login


[root@station1 Downloads]# echo $JAVA_HOME
/usr/java/jdk1.7.0_07/



      Step 2: Download and Unpack apache-tomcat-7.0.30 (or latest)


To download latest  apache-tomcat

[root@station1 Downloads]# tar -xzvf apache-tomcat-7.0.30.tar.gz
[root@station1 Downloads]# mv apache-tomcat-7.0.30 /usr/share/
[root@station1 Downloads]# vim /etc/init.d/tomcat
   #!/bin/bash
    # description: Tomcat Start Stop Restart
    # processname: tomcat
   # chkconfig: 234 20 80
    JAVA_HOME=/usr/java/jdk1.7.0_07
    export JAVA_HOME
    PATH=$JAVA_HOME/bin:$PATH
    export PATH
    CATALINA_HOME=/usr/share/apache-tomcat-7.0.30

    case $1 in
    start)
    sh $CATALINA_HOME/bin/startup.sh
    ;;
    stop)
    sh $CATALINA_HOME/bin/shutdown.sh
    ;;
    restart)
    sh $CATALINA_HOME/bin/shutdown.sh
    sh $CATALINA_HOME/bin/startup.sh
    ;;
    esac
    exit 0
[root@station1 ~]# chmod 755 /etc/init.d/tomcat
[root@station1 ~]# chkconfig --add tomcat
[root@station1 ~]# chkconfig --level 234 tomcat on
[root@station1 ~]# chkconfig --list tomcat
tomcat             0:off    1:off    2:on    3:on    4:on    5:off    6:off
[root@station1 ~]# service tomcat stop
Using CATALINA_BASE:   /usr/share/apache-tomcat-7.0.30
Using CATALINA_HOME:   /usr/share/apache-tomcat-7.0.30
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.30/temp
Using JRE_HOME:        /usr/java/jdk1.7.0_07
Using CLASSPATH:       /usr/share/apache-tomcat-7.0.30/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.30/bin/tomcat-juli.jar

[root@station1 ~]# service tomcat start
Using CATALINA_BASE:   /usr/share/apache-tomcat-7.0.30
Using CATALINA_HOME:   /usr/share/apache-tomcat-7.0.30
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.30/temp
Using JRE_HOME:        /usr/java/jdk1.7.0_07
Using CLASSPATH:       /usr/share/apache-tomcat-7.0.30/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.30/bin/tomcat-juli.jar

[root@station1 ~]# service tomcat restart
Using CATALINA_BASE:   /usr/share/apache-tomcat-7.0.30
Using CATALINA_HOME:   /usr/share/apache-tomcat-7.0.30
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.30/temp
Using JRE_HOME:        /usr/java/jdk1.7.0_07
Using CLASSPATH:       /usr/share/apache-tomcat-7.0.30/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.30/bin/tomcat-juli.jar
Using CATALINA_BASE:   /usr/share/apache-tomcat-7.0.30
Using CATALINA_HOME:   /usr/share/apache-tomcat-7.0.30
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.30/temp
Using JRE_HOME:        /usr/java/jdk1.7.0_07
Using CLASSPATH:       /usr/share/apache-tomcat-7.0.30/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.30/bin/tomcat-juli.jar


For logs


[root@station1 ~]# less /usr/share/apache-tomcat-7.0.30/logs/catalina.out
We can now access the Tomcat Manager page at
[root@station1 ~]# firefox http://station1.com:8080


copy the jenkins.war file to the tomcats


Jenkins home dir will be /root/.jenkins


We can access jenkins






step 2


-- Configure jenkins for git -- need to add plugins from --> manage plugins


-- create new jobs for each product  ( eg:somedomain.com )



step 3


Create Bit Bucket accounts


-- Add accounts in bit bucket at product level eg: somedomain1, somedomain2, etc
       


-- Separate email ids need to be created for each product eg: project1@domain.com,porject2@domain.com
    -- cretate product level repo :
    -- Upto 5 users per account can be added at no cost as per bit bucket pricing terms
       -- emails will be sent to each team members


   


-- install git in  local machine , follow inrustions "start from stratch "  ( this could be done a git-gui client )
     -- updated .git/config file
      [user]
            name = agnello
            email = agnello@domain.com


     -- steps to be follwoed 1st time on local machine  by TL
           mkdir /path/to/your/project
        cd /path/to/your/project
        git init
           git remote add origin https://<<the https URL from BB>>



     -- step to be done on Developer machines
         -- install git-core
         -- access BB URL from the email he would recv .
         -- Once he logs into BB -- systems team will auth him to grant access to repo.
         -- on the linux/ubuntu  Konsole he creats a clone repo



Cloning into cs442-spring12-jdoe...
Username: jdoe
Password: *********
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.

$ ls
cs442-spring12-jdoe/


Adding files and commiting to the local repository
$ cd cs442-spring12-jdoe

$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       MyNewProject/
nothing added to commit but untracked files present (use "git add" to track)

$ git add MyNewProject


$ git config user.name "John Doe"

$ git config user.email "jdoe@hawk.iit.edu"

$ git commit -m "Initial commit for MyNewProject"
[master 453a4f8] Initial commit for MyNewProject
7 files changed, 416 insertions(+), 0 deletions(-)
create mode 100644 MyNewProject/MyNewProject.xcodeproj/project.pbxproj
create mode 100644 MyNewProject/MyNewProject/AppDelegate.h
create mode 100644 MyNewProject/MyNewProject/AppDelegate.m
create mode 100644 MyNewProject/MyNewProject/MyNewProject-Info.plist
create mode 100644 MyNewProject/MyNewProject/MyNewProject-Prefix.pch
create mode 100644 MyNewProject/MyNewProject/en.lproj/InfoPlist.strings
create mode 100644 MyNewProject/MyNewProject/main.m

$ git log
commit 048c71c22f1d38b1a4c8cb73be55ce351fea641b
Author: John Doe <jdoe@hawk.iit.edu>
Date:   Wed Feb 15 22:01:34 2012 -0600

    Initial commit for MyNewProject


commit 3caa74862b8f17f356841bfa2d380a817f371ffe
Author: Michael Lee <lee@soi2.org>
Date:   Thu Jan 12 16:48:59 2012 -0600

    Adding initial README


commit 12cb858e8ecb869d9dc1489283741c9897a3b7f9
Author: Michael Lee <lee@soi2.org>
Date:   Thu Jan 12 16:37:00 2012 -0600

    Adding Xcode gitignore






step 4


-- On Jenkins server , Login as Jenkins, run ss-keygen
-- copy the  .ssh/id_rsa.pub to bit bucket ( with account project1@domain.com ) this is done so that jenkins can connet to BB with our password
-- Add at the New Job level  --> configuration -- > source code managt --> <<  ssh URl from BB >>



step 5


-- In "Manage Jenkins" --> E-mail Notification -->


smtp server  -- smtp.gmail.com
Default user e-mail suffix  --  username@domain.com
-- check "Use SMTP Authentication"
user name  -- jenkins@domain.com
password --- !jenkins@345
use ssl --
smtp port -- 465
Reply-To Address  -- noreply@domain.com




Step 6


installing ant
yum install ant


installing maven


cd /tmp
tar zxvf apache-maven-3.0.5-bin.tar.gz
mv apache-maven-3.0.5 /usr/local/
vi /etc/profile.d/maven.sh
export PATH=/usr/local/apache-maven-
3.0.5/bin:$PATH










installing plugins:  installed the following jenkins plugin


phing
checkstyle
cloverphp
dry
htmlpublisher
jdepend
plot
pmd
violations
xunit



installing all the pear modules .


pecl install xdebug
pear channel-discover pear.pdepend.org
pear install pdepend/PHP_Depend
pear channel-discover pear.phpmd.org
pear install phpmd/PHP_PMD
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install phpunit/phploc
pear install PHPDocumentor
pear install PHP_CodeSniffer
pear install phpunit/PHP_CodeBrowser
pear install phpunit/PHPUnit
pear install phpunit/ppw
pear install Zend_Framework
pear channel-discover pear.zfcampus.org
pear install zfcampus/ZF
pear channel-discover pear.phing.info
pear install phing/phing



step 7


Update On Jenkins


Understanding of git - branches


there are two branches " master " and " development "



-------------------------------------------------------------
These step are used to check into master 1st time


git init
git remote add origin ssh://git@bitbucket.org/agnellodsouza/somedomain1.git
git add .
git commit -m "First commit"
git push -u origin master


--------------------------------------------------------------


On the developers desktop


git clone -b development ssh://git@bitbucket.org/agnellodsouza/somedomain1.git
git branch development
git checkout development

<<< developer makes some changes to the file README >>>

git push -u origin development
git add .
git commit -m "made changes to README "
git push -u origin development



<< again developer pulls from developement branch >>

git branch
git pull origin development



Once developer checks into the Developer branch jenkins will check if any commits have been made ever 5 min . If it see change in commit it will start the build


-- poll from development branch
-- invoke ant -- using the build.xml
-- run various test  ( currently no php unit test for someproject.com)
-- if build successful
-- Using the Git Publisher plugin , will commit to the master branch and create a separate  TAG branch.





Here are few install plugins in for Jenkins :




------------------------------------------------------------------------------------------------


The content of build.xml file that ant need to invoke


<?xml version="1.0" encoding="UTF-8"?>


<project name="Sample project" default="build">
<target name="build"    depends="prepare,lint,perltestcases,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpcb,phpdoc"/>


<target name="build-parallel"
  depends="prepare,lint,tools-parallel,phpcb"/>


<target name="tools-parallel"
        description="Run tools in parallel">
 <parallel threadCount="2">
  <sequential>
    <antcall target="pdepend"/>
    <antcall target="phpmd-ci"/>
  </sequential>
  <antcall target="phpcpd"/>
  <antcall target="phpcs-ci"/>
  <antcall target="phploc"/>
 </parallel>
</target>


<target name="clean" description="Cleanup build artifacts">
 <delete dir="${basedir}/build/api"/>
 <delete dir="${basedir}/build/code-browser"/>
 <delete dir="${basedir}/build/coverage"/>
 <delete dir="${basedir}/build/logs"/>
 <delete dir="${basedir}/build/pdepend"/>
 <delete dir="${basedir}/build/phpdox"/>
 <delete dir="${basedir}/build/code-browser"/>
</target>


<target name="prepare" depends="clean"
        description="Prepare for build">
 <mkdir dir="${basedir}/build/api"/>
 <mkdir dir="${basedir}/build/code-browser"/>
 <mkdir dir="${basedir}/build/coverage"/>
 <mkdir dir="${basedir}/build/logs"/>
 <mkdir dir="${basedir}/build/pdepend"/>
 <mkdir dir="${basedir}/build/phpdox"/>
 <mkdir dir="${basedir}/build/code-browser"/>
</target>




<target name="lint">
 <apply executable="php" failonerror="true">
  <arg value="-l" />


  <fileset dir="${basedir}/src">
    <include name="**/*.php" />
    <modified />
  </fileset>


 </apply>
</target>



<target name="perltestcases">
<property name="perl" location="/usr/bin/perl"/>
<property name="wrapper" location="${basedir}/wrapper2.pl"/>
<exec executable="${perl}" spawn="false">
<arg value="${wrapper}"/>
<arg value="${jobid}"/>
</exec>
</target>


<target name="phploc" description="phploc can be used to track project size metrics, such as Lines of Code (LOC)">
 <exec executable="phploc">
  <arg value="--log-csv" />
  <arg value="${basedir}/build/logs/phploc.csv" />
  <arg path="${basedir}/src" />
 </exec>
</target>


<target name="pdepend"
        description="Calculate software metrics using PHP_Depend">
 <exec executable="pdepend">
  <arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
  <arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
  <arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
  <arg path="${basedir}/src" />
 </exec>
</target>


<target name="phpmd"
        description="Perform project mess detection using PHPMD">
 <exec executable="phpmd">
  <arg path="${basedir}/src" />
 <mkdir dir="${basedir}/build/phpdox"/>
 <mkdir dir="${basedir}/build/phpdox"/>
  <arg value="text" />
  <arg value="${basedir}/build/phpmd.xml" />
 </exec>
</target>


<target name="phpmd-ci"
        description="Perform project mess detection using PHPMD">
 <exec executable="phpmd">
  <arg path="${basedir}/src" />
  <arg value="xml" />
  <arg value="${basedir}/build/phpmd.xml" />
  <arg value="--reportfile" />
  <arg value="${basedir}/build/logs/pmd.xml" />
 </exec>
</target>


<target name="phpcs"
        description="Find coding standard violations using PHP_CodeSniffer">
 <exec executable="phpcs">
  <arg value="--standard=${basedir}/build/phpcs.xml" />
  <arg path="${basedir}/src" />
 </exec>
</target>


<target name="phpcs-ci"
        description="Find coding standard violations using PHP_CodeSniffer">
 <exec executable="phpcs" output="/dev/null">
  <arg value="--report=checkstyle" />
  <arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
  <arg value="--standard=${basedir}/build/phpcs.xml" />
  <arg path="${basedir}/src" />
 </exec>
</target>


<target name="phpcpd" description="Find duplicate code using PHPCPD">
 <exec executable="phpcpd">
  <arg value="--log-pmd" />
  <arg value="${basedir}/build/logs/pmd-cpd.xml" />
  <arg path="${basedir}/src" />
 </exec>
</target>


<target name="phpcb"
        description="Aggregate tool output with PHP_CodeBrowser">
 <exec executable="phpcb">
  <arg value="--log" />
  <arg path="${basedir}/build/logs" />
  <arg value="--source" />
  <arg path="${basedir}/src" />
  <arg value="--output" />
  <arg path="${basedir}/build/code-browser" />
 </exec>
</target>


<target name="phpdoc"
       description="Generate API documentation using PHPDocumentor">
  <exec executable="phpdoc">
  <arg value="--directory" />
  <arg path="${basedir}/src" />
  <arg value="--target" />
  <arg path="${basedir}/build/api" />
  </exec>
</target>


</project>


--------------------------------------------------------------------------------






Sonar intergration with jenkins using maven


sonar + maven + jenkins


we leave the sonar conf file as default
/usr/local/bin/sonar-3.5.1/conf/sonar.properties


setting for maven
/usr/local/bin/apache-maven-3.0.5/conf/settings.xml


<profile>
<id>sonar-profile</id>
<properties>
<sonar.language>php</sonar.language>
</properties>
</profile>


<activeProfiles>
    <activeProfile>sonar-profile</activeProfile>
</activeProfiles>





setting the pom.xml for maven ( this is to be set a individual project level )



<project>
<modelVersion>4.0.0</modelVersion>
<groupId>arsapi</groupId>
<artifactId>arsapi</artifactId>
<name>ars</name>
<version>1.0</version>
<packaging>pom</packaging>
<build>
<directory>build</directory>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
</build>


<properties>
<sonar.language>php</sonar.language>
<sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
<sonar.phpDepend.shouldRun>true</sonar.phpDepend.shouldRun>
<sonar.phpDepend.exclude>vendor/, app/, bin/, web/, src/*/Bundle/*Bundle/Tests</sonar.phpDepend.exclude>
<sonar.phpPmd.shouldRun>true</sonar.phpPmd.shouldRun>
<sonar.phpPmd.analyzeOnly>false</sonar.phpPmd.analyzeOnly>
<sonar.phpCodesniffer.shouldRun>true</sonar.phpCodesniffer.shouldRun>
<sonar.phpcpd.shouldRun>true</sonar.phpcpd.shouldRun>


<sonar.phpUnit.coverage.skip>true</sonar.phpUnit.coverage.skip>
<sonar.phpUnit.skip>true</sonar.phpUnit.skip>


</properties>


</project>



in Jenkins go to the manage configuration and set the maven path .




admin / password



Here are few more imp links :

































very imp docs













automating linux ebook

auto start all xen servers

#!/bin/bash

sleep 10


VMS=(news-db vweb1 vweb2 vweb3 vweb4 bwin01)  

for vm in ${VMS[@]}
do

if [ -e "/etc/xen/$vm" ] # Check if file exist
then
data=`date '+%d/%m/%Y - %H:%M:%S'` # Current date/time (log purposes)
echo "starting at: $data -- $vm"
#######/usr/sbin/xm create $vm # Create VM
#######sleep 15 # Wait 15 sec to start the next
echo
continue # Next VM
fi

echo "Nothing to be done..."

done

exit 0

jobs in AUS

Back up script in perl using rsync , File::Find and Archive::Tar

the Following is a back up script to take back up from remote servers using rsync 

The script can do the following : 

1) reads config file , check the config file if the remote file exists 

2) does an rsync of remote  dir to backupServer 

3) does a tar of the back up in archive dir of the backup server 

4) remove all files that are 60 days older ( currently disabled ) 

5) sends a mail in  case any errors  




-------------------------------------------------------
 this is your /script/backup_scripl.pl
-------------------------------------------------------
#!/usr/bin/perl 

use strict ; 
use warnings;
use Data::Dumper ; 
use Net::SMTP;
use File::Find;
use Archive::Tar;
######################################



our %Config;

require('/<PATHTOCONFIFFILE>/config_backup.pl');



my $F1    ='/var/www/projects/';
my $F2    ='/backup/apps/DocRoot/';
my $ARCH  ='/backup/apps/DocRoot/archive/';
my $today = `date +%F`; chomp($today);
my $now   =`date +%d%b-%H:%M`;  chomp($now);
my $log   ="/backup/docroot-backup1.log";
my $KEY   ="/opt/.securekey/id_rsa";
my $commonip = '10.0.1.' ;
my $hostname =`hostname -i`; chomp($hostname);


unless  ( -e $F2   ) { 
  sendemail("ALERT - DocRoot Backup - Storage Path ABSENT ","Storage location $F2 was not found in the system at `date`. \nTerminating DocRoot backup process at stage1. \nServer is $hostname"); 
  logit(" Backup Alert - $F2 STOR ABSENT");
  exit ;

unless  ( -e $F2   ) { 
  sendemail("ALERT - DocRoot backup Alert - Write Error on storage","Apparently I CANNOT write to $F2/testtouch on `date`. \nTerminating backup process at stage1.\nServer is $hostname "); 
  logit(" Backup Alert - storage is probably readonly. Cannot write to $F2 ");
  exit;

logit("---------------------------- START TIME $now ---------------------------------------- ");

foreach my $web ( keys %Config )  {
  logit(" Start server $web");

  foreach my $server( keys %{$Config{$web}} )  {
    print  "/usr/bin/rsync -e \"ssh -i $KEY  \"  --delete -au root\@$commonip$server:$Config{$web}{$server}[1]$Config{$web}{$server}[0]  $F2$Config{$web}{$server}[0].$server.proj\n" ;
    system("/usr/bin/rsync -e \"ssh -i $KEY \"  --delete -au  root\@$commonip$server:$Config{$web}{$server}[1]$Config{$web}{$server}[0]  $F2$Config{$web}{$server}[0].$server.proj") ;
    logit("$F2$Config{$web}{$server}[0].$server.proj Rsync completed ... ");


  }
  logit(" End  server ") ;

}


foreach my $web ( keys %Config )  {

  foreach my $server  ( keys %{$Config{$web}} )  {

    if ( -e  "$F2$Config{$web}{$server}[0].$server.proj" ) { 

      if ( chdir("$F2$Config{$web}{$server}[0].$server.proj") ) {                
      print "  tar --use=lbzip2 -c -f $ARCH$Config{$web}{$server}[0].$server.proj-$today.tbz2 . 2>/dev/null \n";
        system("tar --use=lbzip2 -c -f $ARCH$Config{$web}{$server}[0].$server.proj-$today.tbz2 . 2>/dev/null");

        if ( $? == 0 ) {  

          logit("Archive of $F2$Config{$web}{$server}[0].$server.proj  to $ARCH$Config{$web}{$server}[0].$server.proj-$today.tbz2  success");
        }else{
          logit("Archive of $F2$Config{$web}{$server}.$server.proj  failed") ;
          sendemail("ALERT - DocRoot backup Alert - Archive Fail", "$now :[STAGE - 2, Server = $hostname ] -- Archive of  $F2$Config{$web}{$server}[0]\.$server\.proj  failed.\nPlease check manually.\nPossible failure due to bad ecit status. Continuing with remaining process." ); 

        }

      } else { 

        logit("NO Dir $F2$Config{$web}{$server}[0].$server.proj ") ; 

      } 

    }else { 

      sendemail("ALERT - DocRoot backup Alert - Archiving Failed","Archiving of $F2$Config{$web}{$server}[0]\.$server\.proj failed  $now  \nTerminating backup process at stage2-Archiving.\nServer is $hostname "); 
      logit("-- Compression Failed....Not Found $F2/$Config{$web}{$server}[0]\.$server\.proj ");


    } 


  }

}

logit("---------------------------- END TIME $now ---------------------------------------- ");


# purge backups older than AGE in days
my @file_list;
my @find_dirs = ($ARCH); # directories to search
my $now_time = time(); # get current time
my $days = 60; # how many days old
my $seconds_per_day = 60*60*24; # seconds in a day
my $AGE = $days*$seconds_per_day; # age in seconds

find ( sub {     my $file = $File::Find::name;
    if ( -f $file ) {
    push (@file_list, $file);
    }
    }, @find_dirs);

for my $file (@file_list) {
  my @stats = stat($file);
  if ($now_time-$stats[9] > $AGE) {
#unlink $file;

    print "unlink $file\n";

  }
}





sub sendemail { 
#usage sendemail("subject","mssg");

  my $from = 'backupserver@yourdomain.com' ;
  my $sub = $_[0] ;
  my $content = $_[1] ;
  my $to = $RCPT ;
  my $relayhost = '10.0.0.22' || 'localhost';

  my $smtp = Net::SMTP->new("$relayhost",
      Debug   => 1,
      );

  $smtp->mail($from);
  $smtp->to($to);
  $smtp->data();
  $smtp->datasend("Subject: $sub");
  $smtp->datasend("\n");
  $smtp->datasend("\n");
  $smtp->datasend("$content");
  $smtp->dataend();
  $smtp->quit();



sub logit {
  my $s = shift;
  my $logtimestamp =`date +%d%b-%H:%M:%S`  ;
  chomp($logtimestamp);

  print "$s\n";
  my $fh;
  open($fh, '>>', "$log") or die "$log: $!";
  print $fh "$logtimestamp : $s\n";
  close($fh);
}

------------------------------------------------------------------------------------------------------------------
this is the config file -- /script/config_backup.pl
------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl

%Config = ( 
    'site1.domain.com'  => {'23 => ['site1-domain','/var/www/html/'] },
    'website2.domain.com'  => {'24' => ['website2-domain.com','/var/www/html/'] },
    'ontravel1.domain.com'  => {'25' => ['ontravel1','/var/www/html/'] },
      ) ;





**** use on your own risk 





Other Articles

Enter your email address: