bash singleton process

Here is a simple, yet effective way, to make sure a script runs only once.
when the script start it run a simple line that detect if the number of running script
does not exceeds more then 1.

[[ `pgrep ${0##*/} | wc -l` > 2 ]] && exit 1

This trick may come handy for example when you run a backup in a cron
and you do not want 2 processes running at the same time .