LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-14-2011, 02:49 PM   #1
kais1
Member
 
Registered: Dec 2008
Posts: 61

Rep: Reputation: 17
check timespan of a process


Dear all,

Am using the below script to get the PID of a process and this works fine

#!/bin/sh
VALUE=`ps -aef | grep "LOSTG" | grep -v grep | awk '{ print $2}'`
TIME=`ps -aef | grep "LOSTG" | grep -v grep | awk '{ print $5}'`
echo $VALUE
echo $TIME

now if the pid is running for more than 1 hour, then it should execute the below command :

then
/opt/OV/bin/OpC/opcmsg application="CONNECT" object="MEDT E7 N MEDFT 40" service_id="CONNECT:MEDT E7 N MEDFT-40" severity=critical msg_text="Process MEDT E7 N MEDFT 40 is not running" msg_grp="INTECONNECT"
fi

How to check the running time of the process ?.. Please advise

Kai

Last edited by kais1; 06-14-2011 at 02:56 PM.
 
Old 06-14-2011, 03:16 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,353
Blog Entries: 55

Rep: Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541
If you mean Process Id of "self" then use "$$". If you mean to grab the PID of another process use 'pgrep' (like 'pgrep -f "init \[[0-9]\]";') instead of 'ps|grep|grep -v grep'. If you want the starting time (within limits) of another process (here: any process called init) try '/bin/ps --no-header -o start_time -C init'. If you want the timer for the current bash script then there's $SECONDS as in '[ $SECONDS -eq $[60*60] ] || echo not yet'?
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check Process hung or not??? jbilla Linux - Server 13 08-09-2010 05:37 AM
How to check disk IO per PROCESS ? dmor Linux - Server 5 09-08-2008 08:50 AM
check process ust Linux - Software 5 03-05-2008 02:46 AM
Check is process is running? Zeno McDohl Programming 2 08-13-2007 07:48 PM
Check the process sunhui Linux - Software 5 03-01-2006 07:07 AM


All times are GMT -5. The time now is 09:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration