Put the lockfile check at the top, so that no temp files get
created. Otherwise an instance run by a user would have to
remove tmp files created by root, if someone attempted to
run it as root.