Forum: Cfengine Help Subject: Check for lockfile Author: berntjernberg Link to topic: https://cfengine.com/forum/read.php?3,21532,21532#msg-21532
Hi all, I have a shell wrapper installing a monitoring agent (not cfengine). The wrapper creates a lock-file so not two instances can run at the same time. On a busy system the installation takes about 25 minutes and the cf-execd runs cf-agent every 15 minutes. I need to check for that lock-file and continue to next promise if it was created less than 45 minutes ago otherwise force an uninstall and cleanup of the software. I came up with this code that works but I wonder if anyone has a better solution. body file_select minutes_old(name,minutes) { leaf_name => { "$(name)" }; ctime => irange(ago(5,0,0,0,0,0),ago(0,0,0,0,"$(minutes)",0)); file_result => "ctime.leaf_name"; } bundle agent check_lockfile { files: "/var/tmp" file_select => minutes_old("file.lck","45"), depth_search => recurse("inf"), action => policy("fix"), transformer => "/usr/bin/echo $(this.promiser)", classes => if_repaired("old_lockfile_exist"); commands: old_lockfile_exist:: ... ... } Any ideas? _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine