Cron Singleton

Fri 03 July 2015 by Godson

Many times we have to run some tasks periodically. 'Cron' is Linux utility intended for such taks.

Now consider following scenario.

You'r performing one non-deterministic task for every 5min using cron utility. And at one point, time to finish a task exceeds 5 min. What will happen in this case ? Another instance of task will be created. In worst case scenarios, there will be hundreds of instances of same task running, ultimately crashing system. To avoid such events, use cron singleton. This singleton ensures that at a time only one instance of taks will be running. Following is example of such singleton.



if ( set -o noclobber; echo "$$" > "$lockfile") 2> /dev/null; then
    trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
    # run job
    echo "Lock Exists: $lockfile owned by $(cat $lockfile)"

Coloring Shell Output

Mon 22 June 2015 by Godson

Coloring Shell

read more

How to Port Knocking in Linux

Fri 19 June 2015 by Godson

To allow clients to ssh using port knocking

@server :

# download knockd rpm from web and install
# rpm -ivh knockd-5.xx.rpm
# rpm -qip knockd-5.xx.rpm - know about the packge
# rpm -ql knockd - to list what are files have installed for knockd

First need to reject ...

read more

How to secure yourself with gpg

Sat 13 June 2015 by Godson

PGP tutorial

read more


Fri 12 June 2015 by Godson

First take one system of centos or ubuntu which ever you like. Make sure have the seperate partitions for LFS and swap which we are going to use fo LFS. Login to the system and create 2 partitions

For Exapmle:
fdisk /dev/sda
# partprobe

Follow same ...

read more