added lockfile support to make sure that when running as a cron that multiple instances do not run
at the same time.