Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Please Help ( Calculate time taken in a script) Post 7758 by sanjay92 on Monday 1st of October 2001 06:05:10 PM
Old 10-01-2001
Hello sskb,
Thanks for your response. I have to write the time or timex command for every shell command. What I want to do is take the difference of time between some line of commands in shell script.



See the example below.

example :-
#!/bin/ksh
# This is just example
# Start the timer
Shell commands ..
Shell commands .

# End of timer

Did you get what I am trying to say.

Sanjay
sanjay92
 

10 More Discussions You Might Find Interesting

1. AIX

calculate time

Hi, How do I calculate time? I need to create an alert if a process is running more than 30 minutes. I need to get the first time and then get another, calculate it if more than 30 mins and then alert it to pager. Can't find it in internet. Thanks in advance, itik (2 Replies)
Discussion started by: itik
2 Replies

2. Shell Programming and Scripting

How to calculate the time difference.

Hi All, I've written a script which reads all the systems backup information and saves it in a log file. ssh -l ora${sid} ${primaryhost} "tail -1 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" | awk '{print $3,$4,$5,$6}' >> ${RESULTFILE} The output comes as below: 2008-09-30 06.00.01... (2 Replies)
Discussion started by: suri.tyson
2 Replies

3. UNIX for Dummies Questions & Answers

calculate the time

hello i want to display the time firstly when i run my shell script and after 25 min i want to display a message it says that the time left is 5 min. When the calculated time is 30 mins, the script should exit. can any one help me with that! Thanks in advance Regards :o (5 Replies)
Discussion started by: dndoon
5 Replies

4. Programming

Calculate time to some date

Hello! I need to find how many days, hours and minutes remain to some specific date and I wonder why the following program shows incorrect values, such as 4 days 23 hours etc to 14:00 this Saturday from 17:33 today... #include <stdio.h> #include <time.h> int main() { time_t elaps,... (4 Replies)
Discussion started by: Sapfeer
4 Replies

5. Shell Programming and Scripting

Calculate average time using a script

Hello, I'm hoping to get some help on calculating an average time from a list of times (hour:minute:second). Here's what my list looks like right now, it will grow (I can get the full date or change the formatting of this as well): 07:55:31 09:42:00 08:09:02 09:15:23 09:27:45 09:49:26... (4 Replies)
Discussion started by: jaredhanks
4 Replies

6. Shell Programming and Scripting

How to calculate time difference between start and end time of a process!

Hello All, I have a problem calculating the time difference between start and end timings...! the timings are given by 24hr format.. Start Date : 08/05/10 12:55 End Date : 08/09/10 06:50 above values are in mm/dd/yy hh:mm format. Now the thing is, 7th(08/07/10) and... (16 Replies)
Discussion started by: smarty86
16 Replies

7. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

8. Shell Programming and Scripting

How to calculate time

Hello Guys, I am trying to calculate total hours and minutes a given user has used the system since the beginning of the current month. #!/usr/bin/sh hr=0 min=0 last $1 | grep -w `date "+%b"` | grep -v '\(0:.*\)' | grep -vw sshd | cut -c 66- | tr -d "\(\)" | cut -f1 -d ":" | grep -v '.*' |... (9 Replies)
Discussion started by: kasparov
9 Replies

9. Shell Programming and Scripting

Calculate time difference

I have time in a file in HH:MM:SS format as it contents(its not the file creation time). i need this to be converted to epoch time or time since 1970. The time is written into that file by a script, which i cannot modify. Im using AIX machine $ cat abc.txt 10:29:34 (2 Replies)
Discussion started by: gpk_newbie
2 Replies

10. Shell Programming and Scripting

Calculate Time diff in milli milliseconds(Time format : HH:MM:SS,NNN)

Hi All, I have one file which contains time for request and response. I want to calculate time difference in milliseconds for each line. This file can contain 10K lines. Sample file with 4 lines. for first line. Request Time: 15:23:45,255 Response Time: 15:23:45,258 Time diff... (6 Replies)
Discussion started by: Raza Ali
6 Replies
exit(1) 							   User Commands							   exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 05:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy