![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to make a script run for a maximum of "x" number of hours only | ScriptDummy | Shell Programming and Scripting | 7 | 10-23-2007 06:51 AM |
| Subtract 2 months from the date | mahekr2000 | UNIX for Advanced & Expert Users | 5 | 07-23-2006 09:01 AM |
| Subtract Time | xadamz23 | Shell Programming and Scripting | 4 | 12-03-2005 11:18 PM |
| Subtract two date in unix | vanand | Shell Programming and Scripting | 1 | 06-18-2005 04:19 AM |
| How to subtract 2 hours from 'date' in shell ( /bin/sh ) script ? | yairon | UNIX for Dummies Questions & Answers | 1 | 06-07-2001 12:23 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
script for add and subtract two hours
i find a script to calculate hours of job i(nclude extraordinary)
i make a script to calculate add and subtract two hours (format hh:mm:ss) |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Do you know about time?
try: Code:
time myscript.sh |
|
#3
|
|||
|
|||
|
Or try:
Code:
start_time=`perl -e 'print time;'`
myscript.sh
elapsed_time=$(echo "`perl -e 'print time;'` - $start_time | bc)
echo "Total time in seconds: $elapsed_time"
Last edited by jim mcnamara; 08-16-2006 at 12:48 PM. Reason: inverted subtraction... |
|
#4
|
||||
|
||||
|
doesn't 'elapsed = finish_time - start_time' and not vice versa?
not sure if you need 'bc' - your math is integer math anyway. |
|
#5
|
|||
|
|||
|
Yup -vgersh - you're right.
Some shells do not do integer math beyond 255. I can't tell what shell. |
|
#6
|
|||
|
|||
|
where is the code ???
time myscript.sh ????
where is the code ??? i search a ssh or ksh script Timesub(time1 time2 ) which return time1-time2 (two string :"hh.mm.ss") can you help me ?? |
|
#7
|
|||
|
|||
|
the propper do to is using epoch. (seconds since 1.1.1970) because if you have DST is can
srew your script very badly. also the math is integer math and therefore very easy. you can use date to convert from and into epoch. |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|