Kshell scripts and timing


 
Thread Tools Search this Thread
Operating Systems AIX Kshell scripts and timing
# 1  
Old 10-10-2006
Kshell scripts and timing

Hello everyone,

I have a script thats acting funky, what I would like to do is report to a file, how long its taking to get to certain area's, in seconds. For example.

-- Start timer
-- Run unix command 1
-- Run unix command 2
-- Stop timer
-- Report Seconds
-- etc etc

Is there a way to do this, or am I really limited to time stamps and manually going through the reports?
# 2  
Old 10-10-2006
Code:
time unix command1 && unix command2

Start with that - it will give time elapsed.
# 3  
Old 10-10-2006
Thanks Jim I will take a look. I think my script might be too complicated for it though unless you can store the time result somewhere and continually add to it, but this is a good start and something to chew on.
# 4  
Old 10-10-2006
From the KSH man page:

Code:
     SECONDS

           Each time this variable is referenced, the  number  of
           seconds  since  shell  invocation is returned. If this
           variable is assigned a value, then the value  returned
           upon  reference  will  be  the value that was assigned
           plus the number of seconds since the assignment.

Save the value of $SECONDS before your process starts and compare to $SECONDS once your process completes.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Difference between kshell and bash shell scripts Example cited

Hi All, I need some urgent help regarding some info. I have a cluster of servers for which I have two scripts for management. control.sh is a bash script meant for restarting/stopping the servers. manger.ksh is a kshell script. It is a master script to manage restarting/stoppping and... (3 Replies)
Discussion started by: ankur328
3 Replies

2. Shell Programming and Scripting

Timing a script

i have a very big script i have that i'd like to add a timeout to. this script runs on a several remote host. i update this script with timeout clause and then copy it over to all the hosts on which it is currently on. basically, i want the timeout to make the script abort/exit if it's... (1 Reply)
Discussion started by: SkySmart
1 Replies

3. Shell Programming and Scripting

Please help with Kshell Script!

I am an AIX noobie, and have a question around an AIX 5.2 script that I need to run. Security Audit requires us to have no World Writable files on our server, but every time we restart the Domino server on AIX it re-flags two files as World Writable. I have a little script that I created that... (5 Replies)
Discussion started by: Nebs
5 Replies

4. Shell Programming and Scripting

KShell regular expresion

Hi, I would like to know if the parameter i am passing to a shell script is contain the following charachter : ASM. I belive that i should use regular expresion here. Can one help ? Bellow is the "if statment" i need to fix with the reg exp: if ; then #echo "IT IS AN RDBMS... (4 Replies)
Discussion started by: yoavbe
4 Replies

5. Shell Programming and Scripting

Substring operation in kshell

Hi, Please let me know how to perform the substring operation in kshell. If i have line like below 238923893282389034893489458945904589045454903490 i would like to retrieve the position 7 to 19, how to do this in kshell? (1 Reply)
Discussion started by: informsrini
1 Replies

6. Shell Programming and Scripting

running .sh script in kshell

hi i wrote a script in shell script(ChangeFiles.sh), now i need to run the script in korn shell. could anyone explain how to run the same script korn shell. thanks in advance Satya (2 Replies)
Discussion started by: Satyak
2 Replies

7. UNIX for Dummies Questions & Answers

kshell variables and awk

Hi, Is it possible to initialise a shell variable and set it to a value from an awk command? i.e. #set myvalue = to the first 8 charachters of the line that begins with 0 myvalue = awk '/^0/ {substr($0,1,8)}' myvaluefile or even declare a variable, then reinitialise it as part of the... (1 Reply)
Discussion started by: kshelluser
1 Replies

8. Programming

timing your functions

hi everyone. If you have a function created in your code and you want to find out how long it takes for it to run you can use a struct called gettimeofday(). so lets say we have a function like this int myfunction (int r) { /*some math calculations*/ return answer; } How do i set up... (3 Replies)
Discussion started by: bebop1111116
3 Replies

9. Shell Programming and Scripting

Timing out a SSH

I need to make it so an autmated process which involves ssh, times out if ssh prompts for a password. Most of the time it shouldnt prompt for a password. But if it does i need it to time it out or get a status and stop the ssh and log that the ssh failed and move onto the next server. Is there any... (9 Replies)
Discussion started by: rcunn87
9 Replies

10. UNIX for Advanced & Expert Users

scp timing out

having problems using scp in that during peak hours it appears to time out. anyone have similar experiences? any thoughts regarding a solution... (1 Reply)
Discussion started by: jph
1 Replies
Login or Register to Ask a Question