Sensible Open Source

Blog Status

  • 4 yrs 48 wks 5 days old
  • Updated: 11 Mar 2010
  • 455 entries
  • 174 comments
Total: 1,214,317
since: 5 Apr 2005

LinkBlogS

Creating Vidcasts

18 June 2007, Monday 7:05 P GMT-06
Tags:      

Man, Can't Microsoft Catch A Break?

16 March 2007, Friday 12:26 P GMT-06

Viacom, Google andYou Tube, Oh My!

16 March 2007, Friday 12:25 P GMT-06

Switch to digital TV to start in October

16 March 2007, Friday 7:46 A GMT-06

Is the Ice Ready? No, Its Still To Hot To Use...

16 March 2007, Friday 7:43 A GMT-06

MIT Entire Curriculum At disposal of e-learners

6 March 2007, Tuesday 11:52 A GMT-06

A cure for e-mail attention disorder?

2 March 2007, Friday 12:51 A GMT-06
Tags:  

Windows-on-Mac software gets virtualization update

1 March 2007, Thursday 5:08 A GMT-06

EnterpriseDB is/n't Open Source

1 March 2007, Thursday 3:37 A GMT-06

BitTorrent download portal debuts

27 February 2007, Tuesday 9:05 A GMT-06

$45b TXU buyout

27 February 2007, Tuesday 9:02 A GMT-06

iPhone Competitors Got The Touch

26 February 2007, Monday 3:43 A GMT-06
Tags:        

HTC - Smart Mobility

25 February 2007, Sunday 4:22 A GMT-06

Hard to find 1-800 numbers

23 February 2007, Friday 8:35 A GMT-06

Cuba Embraces Open-Source Software

21 February 2007, Wednesday 3:10 A GMT-06

Vista at the tipping point, Err Dipping Point?

11 February 2007, Sunday 11:11 A GMT-06
Tags:  

PostgreSQL Open Source And Persistence

3 February 2007, Saturday 10:32 P GMT-06

Blackboard Pledges No Patent Blocks

3 February 2007, Saturday 10:28 P GMT-06

UVU

5 January 2007, Friday 11:58 P GMT-06

Open-source IP PBX software appliance"

4 January 2007, Thursday 3:44 A GMT-06

Asterisk an under-appreciated Open Source Success Story

4 January 2007, Thursday 3:43 A GMT-06

Open Source AJAX Tooling

4 January 2007, Thursday 3:41 A GMT-06

Google MAIL API Secuirty Alert

1 January 2007, Monday 7:37 P GMT-06
Tags:    

United States Patent Application: 0060288329

26 December 2006, Tuesday 4:00 A GMT-06

LinkBlog Popular Tags

                                       







««Mar 2010»»
SMTWTFS
  12
3
456
789
10
111213
14151617181920
21222324252627
28293031

 

August 16, 2012

Time Left

2 years 5 months 4 days

                   

RSS Add-Me








Google Related Links

Need a TimeStamp In Your Bash?

posted 1 February 2010, Monday

Bash scripting is a requirement in production environments.  On your personal computer, be it a MAC or Linux!  (Windows scripting is important and one can use bash provided CYGWIN or similar is installed).  However, the point here is sometimes you want to know how long your script runs.

Here is a quick, 30 seconds or less implementation to add to your script  to have a proper time stamp issued in a log or to terminal.

It's really simple, just using the date command and exporting that in to an environment variable to save the start.  Than issuing another date at the scripts operational end.

The mechanism used to save the start in an environment variable, just as an example this was named as TimeNowEnv.

This is saved upon operational end as we issue the call to date to get another timestamp (In this case the end). Once this is displayed we issue an 'unset TimeNowEnv' just to clean things up.  This could be issued several times in the script so this is just a housekeeping task.

In file TimeMe.sh 

export TimeNowEnv=$(date)
echo 'Start: ' $TimeNowEnv

sleep 30
echo 'End:' $(date)
unset TimeNowEnv

Execution is ./TimeMe.sh and will print the start, than, to simulate an operation the script sleeps (sleep 30) for 30 seconds and than prints the operational end.  Output below:

 

[prod@ZAP scripts]$ ./TimeMe.sh

Start:  Mon Feb 1 14:49:21 CST 2010

End: Mon Feb 1 14:49:51 CST 2010

Taking the above first two lines and putting it at the top of your script and the last two lines at the bottom is all you need.
 
That's it....  Told it was simple!  
 
....sos out 

 

tags:                  

links: digg this    del.icio.us    technorati    reddit