AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
Expand all | Collapse all

Basic uptime script to notify admin more than 90 days

  • 1.  Basic uptime script to notify admin more than 90 days

    Posted Tue October 26, 2010 06:31 PM

    Originally posted by: Revdigby


    Hello,

    I am searching for a basic script (or how to script) for the command uptime to notify me via email when a system has been online for more than 90 days.
    #AIX-Forum


  • 2.  Re: Basic uptime script to notify admin more than 90 days

    Posted Mon November 01, 2010 01:41 AM

    Originally posted by: SystemAdmin


    Here is a very basic script. Test, modify, and run from crontabs.

    #!/usr/bin/ksh
    days_to_email=90
    uptime | uptimeLine=$(line)
    set $uptimeLine
    days=$3

    email_list="user@domain"
    if [ $days -gt $days_to_email ]; then
    cat <<- EOF | mailx -s "Overdue reboot on $(hostname)" $email_list
    Hi from root on $(hostname),

    The uptime command shows: $uptimeLine

    It may be time for a reboot?
    EOF
    fi
    #AIX-Forum