LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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-08-2013, 07:54 AM   #1
ali_nmp
LQ Newbie
 
Registered: Jun 2013
Posts: 6

Rep: Reputation: Disabled
ali_nmp


hi, i'm new in linux scripting. i have question please help me! how can get times between for example {12:00:00, 13:00:00} in scripting!like 12:05:15 or 12:59:59 etc!
regardless ali_nmp
 
Old 06-08-2013, 09:57 AM   #2
shm0
Member
 
Registered: Aug 2012
Location: Bahrain
Distribution: Slackware
Posts: 58

Rep: Reputation: 16
Quote:
Originally Posted by ali_nmp View Post
hi, i'm new in linux scripting. i have question please help me! how can get times between for example {12:00:00, 13:00:00} in scripting!like 12:05:15 or 12:59:59 etc!
Which scripting language are you trying to use? And what do you mean by "get times"? Do you mean random time?
 
Old 06-08-2013, 10:05 AM   #3
ali_nmp
LQ Newbie
 
Registered: Jun 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
i'm using bash scripting language. No i'm writing a script that get all process that is running between specify time for e.g 12:00:00 till 13:00:00, how can get it?
its my script:

#!/bin/bash

num=0
echo -n "Enter a number: > "
read num
ps -eo pid,start,cmd | awk '$2<expr$(date +"%T"- $num)'| grep "[o]racle${ORACLE_SID}.*(LOCAL=NO).*$"
 
Old 06-10-2013, 12:57 AM   #4
ali_nmp
LQ Newbie
 
Registered: Jun 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
maybe it is better that i describe my question in anther way! assume, i wrote a script e.g test.sh and i wanna execute it like bash.sh 5.
i wanna it get all process that is running of 5 hours ago till currently time. how can i do it?

Last edited by ali_nmp; 06-10-2013 at 04:45 AM.
 
Old 06-10-2013, 01:29 AM   #5
shm0
Member
 
Registered: Aug 2012
Location: Bahrain
Distribution: Slackware
Posts: 58

Rep: Reputation: 16
Quote:
Originally Posted by ali_nmp View Post
maybe it is better that i describe my question in anther way! assume, i wrote an script e.g test.sh and i wanna execute it like bash.sh 5.
i wanna it get all process that is running of 5 hours ago till currently time. how can i do it?
Instead of "start" in your command, you should use one of the following:
etime: elapsed time since the process was started
bsdtime: accumulated cpu time, user + system.
cputime: cumulative CPU time
 
Old 06-11-2013, 02:33 AM   #6
ali_nmp
LQ Newbie
 
Registered: Jun 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
sorry dear, i didn't understand, please tell me more about it
tnx
 
Old 06-11-2013, 02:49 AM   #7
shm0
Member
 
Registered: Aug 2012
Location: Bahrain
Distribution: Slackware
Posts: 58

Rep: Reputation: 16
Quote:
Originally Posted by ali_nmp View Post
#!/bin/bash

num=0
echo -n "Enter a number: > "
read num
ps -eo pid,start,cmd | awk '$2<expr$(date +"%T"- $num)'| grep "[o]racle${ORACLE_SID}.*(LOCAL=NO).*$"
Instead of:
Code:
ps -eo pid,start,cmd
try:
Code:
ps -eo pid,etime,cmd
 
Old 06-12-2013, 01:06 AM   #8
ali_nmp
LQ Newbie
 
Registered: Jun 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
thanks so much brother
 
  


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



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:42 AM.

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
Open Source Consulting | Domain Registration