isnewerthantime
Table of contents
Prototype: isnewerthantime(file, time)
Return type: boolean
Description: Returns whether the file file
is newer (modified later)
than the time time
.
This function compares the modification time (mtime) of the file. Note that access changes such as ownership and permissions as well as status changes such as last time the file was read are not included in the mtime timestamp.
Arguments:
file
:string
- File name - in the range:"?(/.*)
time
:int
- Time as a Unix epoch offset - in the range:0,99999999999
Example:
Prepare:
code
touch -t '200102031234.56' /tmp/file_a
touch -t '200202031234.56' /tmp/file_b
Run:
code
body common control
{
bundlesequence => { "example" };
}
bundle agent example
{
classes:
"is_file_a_new" expression => isnewerthantime("/tmp/file_a", 1000000000);
"is_file_b_new" expression => isnewerthantime("/tmp/file_b", 1000000000);
reports:
!is_file_a_new::
"/tmp/file_a is not newer than 2001-09-09 01:46:40";
is_file_b_new::
"/tmp/file_b is newer than 2001-09-09 01:46:40";
}
Output:
code
R: /tmp/file_a is not newer than 2001-09-09 01:46:40
R: /tmp/file_b is newer than 2001-09-09 01:46:40
See also: isnewerthan()