C8 - Automate

Embed Size (px)

Citation preview

  • 8/3/2019 C8 - Automate

    1/19

    notification

    Tutor: Lu Thanh Tr

    Email: lttra hoasen.edu.vn

  • 8/3/2019 C8 - Automate

    2/19

    Outline

    Scheduling utilities

  • 8/3/2019 C8 - Automate

    3/19

    mail and mailx

    mail -s This is the subject $MAILOUT_LIST < $MAIL_FILE

    OR

    cat $MAIL_FILE | mail -s This is the subject $MAILOUT_LIST

    ma x -s s s t e su ect _ < _

    OR

    cat $MAIL_FILE | mailx -s This is the subject $MAILOUT_LIST

  • 8/3/2019 C8 - Automate

    4/19

    _

    $MAIL_FILE : email content

  • 8/3/2019 C8 - Automate

    5/19

    Example with mail/mailxMAIL_FILE=/tmp/mailfile.out

    cat /dev/null > $MAIL_FILE

    [email protected]@mypage_somebody.net

    check_filesystems

    # This function checks the filesystems percentage

    if [ -s $MAIL_FILE ]

    then

    mail -s Filesystem Full $MAIL_LIST < $MAIL_FILEfi

    Note: -v for debug

  • 8/3/2019 C8 - Automate

    6/19

    _

    {=

    PERCENT=98

    = -

    echo $THISHOST: $FS is $PERCENT | tee -a $MAIL_FILE

    }

    Note: ps -eo pid,pcpu,comm|egrep -v 0.0|sort -r -k2

  • 8/3/2019 C8 - Automate

    7/19

    sendmail1. function send_notification

    2.

    3. if [ -s $MAIL_FILE -a $MAILOUT = TRUE ];4. then

    .

    6. AIX|HP-UX|Linux) SENDMAIL=/usr/sbin/sendmail

    7. ;;8. SunOS) SENDMAIL=/usr/lib/sendmail

    9. ;;

    10. esac

    11. echo \nSending email notification

    12. $SENDMAIL -f randy@$THISHOST $MAIL_LIST enscript -Pcsl csci330.csh

    at> commands will be executed using /bin/sh

    o a u ec : :

  • 8/3/2019 C8 - Automate

    17/19

    at utilities

    atq

    s s user s sc e u e o s

    atrm

    removes specified job from at queue

  • 8/3/2019 C8 - Automate

    18/19

    batch command

    batch

    schedules job to be performed when systemload is lowsame program as a

    yn ax:

    % batch command

    on turing: lowmeans load is less than 1.5

  • 8/3/2019 C8 - Automate

    19/19

    Login Accounting

    wtm DB of all lo ins and lo outs

    Time User/TTY

    Where

    utmp DB of currently logged in users

    who/w Lists currently logged in users

    last Lists all lo in sessions

    lastlog List last time users logged in