Sunday, May 21, 2017

Error while starting jenkins

Today, when I install and setup Jenkins, I am getting the following error while starting the jenkins service.

OS : CentOS release 6.8 (Final)

Following is the error:

Running from: /usr/lib/jenkins/jenkins.war
May 21, 2017 7:38:37 PM Main deleteWinstoneTempContents
WARNING: Failed to delete the temporary Winstone file /tmp/winstone/jenkins.war
Jenkins requires Java7 or later, but you are running 1.7.0_131-mockbuild_2017_02_13_15_19-b00 from /usr/lib/jvm/java-1.7.0-openjdk-
java.lang.UnsupportedClassVersionError: winstone/Launcher : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(
        at Method)
        at java.lang.ClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
        at Main._main(
        at Main.main(

Solution to fix the issue:

1. Take the backup of /etc/init.d/jenkins to a safe location.
2.  update-alternatives --config java (to the latest java) 
3. Update the file /etc/init.d/jenkins after candidates with your result of echo $JAVA_HOME

The  /etc/init.d/jenkins snippet is below
# Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins.
# see

4. Restart jenkins

Tuesday, May 2, 2017

Patching 0 for a variable in python

As part of a program logic, i need to patch 0 for a variable to make sure the total length of the string is 3.

Here the variable name is shivin

shivin = shivin.zfill(3)
return shivin

Wednesday, April 5, 2017

How to sort the contents of a file in linux

How to sort the contents of a file in linux

I have a file in a path /tmp which contains some rpm packages. I need to sort the file.

ll /tmp/pckg.txt
sort /tmp/pckg.txt > /tmp/s_pckg.txt
A new file /tmp/s_pckg.txt will be created and the contents in that file will be in sorted order.

sort -r /tmp/pckg.txt > /tmp/s_pckg.txt
Reverse sorted.

sort -nk2 /tmp/s_pckg.txt
On the basis of second column it will sort.

Useful command combination in System Administration

Useful command combination in System Administration

Once you are in a linux box, these commands will help you to save your time a lot.

[root@linuxblack tmp]# ps aux|grep nagios | awk '{print $2}'|xargs kill -9 to kill the process owned by nagios

[root@linuxblack tmp]# ll | grep 02:1| awk '{print $9}'| xargs gzip list and zip the files in a dir whose time is 02:1

[root@linuxblack tmp]# ll | grep Jul| awk '{print $9}'| xargs du -hs - list and display the disk usage

[root@linuxblack tmp]# lsof -i TCP:443|awk '{print $2}'|xargs kill -9 Kill the process listening on port 443