shell - Record command execution time -


There is a lovely way of logging in the initial date / time of all the commands in the Linux console, you have the variable HISTTIMEFORMAT "% F% T "Then you will see something by running the 'history' command:

 512 2011-09-02 22:57:41 Export HISTTIMEFORMAT ="% F% T "513 2011-09-02 22: 57: 42 LS 514 2011-09-02 22:57:43 History 515 2011-09-02 22:57:45 History  

This is very cool and useful. But my dream is to command this log also to have exec execution time. I know that I can run 'time./some_long_read_script', but do not want to manually write time each time. What is a way to save every command execution time?

If it is also not distracted, change your signal to display the current date and time You can.

If you are using bash, consider something like this:

  export PS1 = "[\ D {% Y-% m-% d} \ T ] [\ U @ \ h \ w] \ $ "  

which will look like this:

  [2011-09-03 03:39:21] [James @ fractal ~] $ echo $ PS1 [\ D %% y-% m-% d} \ T] [\ u @ \ h \ w] $ [2011- 09-03 03:39:30] [James Fractal ~] $ vi [2011-09-03 03:39:39] [James Fractal ~] $ ping google.com Ping google.com (74.125.93.147) 56 (84) Bytes of data 64 bytes Qi-in-F From 147.1A 100.net (74.125.93.147): ICMP_reck = 1 ttl = 47 time = 51.3 ms ^ C --- GOF Ping statistics --- 1 packet sent, 1 received, 0% packet Damage, time 0ms rtt min / avg / max / mdev = 51.343 / 51.343 / 51.343 / 0.000 ms [2011-09-03 03:39:44] [james @ fractal ~] $   << P> You can definitely start your personal preferences.  

To change your prompts permanently, you need to enter that code in your ~ / .bashrc file for export PS1 = ... . Alternatively, you can type aliases in to your ~ / .bashrc file toggle, back and forth,

  alias prompt_ts_on = 'export $ PS1 = .. 'Alias ​​prompt_ts_off =' export $ PS1 = "[\ u @ \ h \ w] \ $" '  

Note that ... Should be some reference on PO1 escape sequence: and

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -