#age(), #fileage()

(NOTE:  Some of the techniques shown or described on this page--marked in purple--require new features in the latest official PIKT 1.19.0 release (pikt-current.tar.gz) that are unavailable in any previous version.)

DESCRIPTION
    returns the age in days since a specified date

    or:

    returns the age in days of a specified file or directory
SYNOPSIS
    #age(s1,s2,s3)
    #fileage(s1,s2,s3)

    or:

#age(s) #fileage(s)
ARGUMENTS
    s1 - a month name, as in "January", "February", ..., or "Jan", "Feb", ...
    s2 - a string, or string expression, representing a date (1-31)
    s3 - a string, or string expression, representing either a four-digit year (yyyy),
         or a time (hh:mm)

    or:

    s - a quoted string, or string expression, representing a file or directory path
EXAMPLES
        rule
                if #maxsecs == 0
                        set #maxage = #maxdays
                        do #split($command("=ll $name"))
                        set #fa = #age($6,$7,$8)
                        if #fa > #maxage
                                output mail "$name is outdated,
                                             is $text(#fa) days old"
                        endif
                else
                        set #maxage = #maxdays * =secs_in_day + #maxsecs
                        set $ll = $command("=ll $name")
                        =set_lineage($ll)
                        if #lineage > #maxage
                                output mail "$name is outdated,
                                             is $text(#lineage) seconds old"
                        endif
                endif
NumberedSyslogFile

        init
                status active
                level notice
                task "To report existence of, and to dispose of, syslog.[0-9]* files"
                input proc "=ll =syslog\.[0-9]* 2> /dev/null"
                =lldata

        rule    // only delete syslog files greater than five days old
                if #fileage($mon,$date,$time) > 5
                        =outputmail "deleting: $inlin"
                        =execwait "=rm -f $name"
                endif
# touch /tmp/foobar

# pikt +C 'output $text(#fileage("/tmp/foobar"))'
0

# pikt +C 'output $text(#fileage("/tmp"))'
0
SEE ALSO
    Numerical Functions
    String Functions
 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
Learn new
techniques for
alert e-mail routing