isnewerthan

Table of Contents

Prototype: isnewerthan(newer, older)

Return type: boolean

Description: Returns whether the file newer is newer (modified later) than the file older.

This function compares the modification time (mtime) of the files, referring to changes of content only.

Arguments:

  • newer: string, in the range: "?(/.*)
  • older: string, in the range: "?(/.*)

Example:

Prepare:

touch -t '200102031234.56' /tmp/earlier
touch -t '200202031234.56' /tmp/later

Run:

body common control
{
      bundlesequence => { "example" };
}

bundle agent example
{
  classes:

      "do_it" and => { isnewerthan("/tmp/later","/tmp/earlier"), "cfengine" };

  reports:

    do_it::

      "/tmp/later is older than /tmp/earlier";
}

Output:

R: /tmp/later is older than /tmp/earlier