Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    272

    Unanswered: Linux shell script

    Can some one give me a script where it determine if a process is running for more than 15 minutes.

    The process name is file_system_check.ksh

    If I do a ps -ef | grep -i file_system_check.ksh | grep -v grep, this process filters out.

    The logic which I need to present in the script is, If the above process is running for more than 15 minutes, then it needs to send an email saying that the process is running for more than 15 minutes.

  2. #2
    Join Date
    Jan 2010
    Posts
    335
    Hi Blazer,

    since your script is for an database-Server i'ld work with DB2-Timestamps. It's easier than doing the Math with dates from the Shell or system.

    At the start of your check-script write the current timestamp into a file:
    db2 -x "values (current timestamp)" > some/file.out // Database-Connection required!

    If you want to test your file_system_check.ksh,
    then

    START_TIME=$(cat some/file.out)
    CHECK_TIME=$(db2 -x "values (current timestamp - $RUNTIME minutes)" )

    if [[ $CHECK_TIME > $START_TIME ]]; then
    mailx -s bla mail@address.com ...
    fi

    Hth
    nvk

  3. #3
    Join Date
    Jun 2009
    Posts
    272
    Thanks NVK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •