added file locking; changed critical_interval variable to seconds instead of minutes
log output starts at ERROR, use -v to increase it