Forum: Cfengine Help
Subject: Re: Controlling Module Calls
Author: nima
Link to topic: https://cfengine.com/forum/read.php?3,18383,18469#msg-18469
Hi Seva,
A reasonable suggestion again, but doesn't work - I must say, some things in
cfengine do not follow any natural set of rules. Anyway, I've ended up writing
such modules as follows:
sc_run_already 3
if [ $? -eq 0 ]; then
...code...
fi
Where the sc_run_already function takes the minimum age that must have passed
since the last run for the module to run again - it is then defined as follows:
SC_MOD_LOCK=/var/lock/cf3.$(basename $0)
function sc_run_already() {
run_already=0
if [ -f ${SC_MOD_LOCK} ]; then
stat=$(sc_stat ${SC_MOD_LOCK})
delta=$((${SC_NOW_EPOCH}-${stat}))
if [ ${delta} -le ${1-9} ]; then
run_already=1
fi
fi
test ${run_already} -ne 0 || touch ${SC_MOD_LOCK}
return ${run_already}
}
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine