Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15590

Re: [FR] save command times and exit status in history automatically

Path csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From L A Walsh <bash@tlinx.org>
Newsgroups gnu.bash.bug
Subject Re: [FR] save command times and exit status in history automatically
Date Sun, 10 Nov 2019 03:38:59 -0800
Lines 83
Approved bug-bash@gnu.org
Message-ID <mailman.1176.1573385948.13325.bug-bash@gnu.org> (permalink)
References <CAKOZuevfhS7veH9+GSc=8StpgrA_vy59Y2fYYGhMDk0OPZb69Q@mail.gmail.com> <8e19b0fc-4183-90fa-b067-9da636998d6f@case.edu> <CAKOZuevFuqrQhH75_-Dpum2VwmUkrP1r7E6b--v=Mg_EVHWuCw@mail.gmail.com> <5DC7F6D3.9090301@tlinx.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1573385949 3599 209.51.188.17 (10 Nov 2019 11:39:09 GMT)
X-Complaints-To action@cs.stanford.edu
Cc Chester Ramey <chet.ramey@case.edu>, "bash.bug list" <bug-bash@gnu.org>
To Daniel Colascione <dancol@google.com>
Envelope-to bug-bash@gnu.org
User-Agent Thunderbird
In-Reply-To <CAKOZuevFuqrQhH75_-Dpum2VwmUkrP1r7E6b--v=Mg_EVHWuCw@mail.gmail.com>
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy]
X-Received-From 173.164.175.65
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <5DC7F6D3.9090301@tlinx.org>
X-Mailman-Original-References <CAKOZuevfhS7veH9+GSc=8StpgrA_vy59Y2fYYGhMDk0OPZb69Q@mail.gmail.com> <8e19b0fc-4183-90fa-b067-9da636998d6f@case.edu> <CAKOZuevFuqrQhH75_-Dpum2VwmUkrP1r7E6b--v=Mg_EVHWuCw@mail.gmail.com>
Xref csiph.com gnu.bash.bug:15590

Show key headers only | View raw


On 2019/11/07 12:18, Daniel Colascione wrote:
>>> statuses? This information is practically free to collect.
>>>       
>> Because by the time you gather this information, the command has already
>> been saved completely.
>>
>> There have been various proposals to extend the timestamp with additional
>> information, but it's all data you can gather when the timestamp is saved
>> before the command is executed.
>>     
> Why not also, optionally, save command execution times and exit
----
This sounds like you want accounting info (?).
Example: I executed a perl command (using 'tperl') that exited with
a status of 12.

The output I got (some spaces trimmed) was:

perl |v3| 1.00| 0.00| 1.00| 5013| 201|
11536.00| 0.00| 98283| 98014|12|pts/2 |Sun Nov 10 03:20:17 2019

That could be merged with history output (my HIST format is
HISTTIMEFORMAT='%m%d@%H%M%S: ')


55325  1110@032011: tperl
exit 12;'
55326  1110@032020: dump-acct -r  /var/account/pacct |more
55327  1110@032419: man 5 acct
55328  1110@033045: history |tail
--------------------

Documented in manpage 'acct(5)':
Fields:

#define ACCT_COMM 16

typedef u_int16_t comp_t;

struct acct {
char ac_flag;           /* Accounting flags */
u_int16_t ac_uid;       /* Accounting user ID */
u_int16_t ac_gid;       /* Accounting group ID */
u_int16_t ac_tty;       /* Controlling terminal */
u_int32_t ac_btime;     /* Process creation time
(seconds since the Epoch) */
comp_t    ac_utime;     /* User CPU time */
comp_t    ac_stime;     /* System CPU time */
comp_t    ac_etime;     /* Elapsed time */
comp_t    ac_mem;       /* Average memory usage (kB) */
comp_t    ac_io;        /* Characters transferred (unused) */
comp_t    ac_rw;        /* Blocks read or written (unused) */
comp_t    ac_minflt;    /* Minor page faults */
comp_t    ac_majflt;    /* Major page faults */
comp_t    ac_swaps;     /* Number of swaps (unused) */
u_int32_t ac_exitcode;  /* Process termination status
(see wait(2)) */
char      ac_comm[ACCT_COMM+1];
/* Command name (basename of last
executed command; null-terminated) */
char      ac_pad[X];    /* padding bytes */
};

enum {          /* Bits that may be set in ac_flag field */
AFORK = 0x01,   /* Has executed fork, but no exec */
ASU   = 0x02,   /* Used superuser privileges */
ACORE = 0x08,   /* Dumped core */
AXSIG = 0x10    /* Killed by a signal */
};

The  comp_t  data type is a floating-point value consisting of a
3-bit, base-8 exponent, and a 13-bit mantissa.  A value, c, of
this type can be converted to a (long) integer as follows:

   v = (c & 0x1fff) << (((c >> 13) & 0x7) * 3);

 The ac_utime, ac_stime, and ac_etime fields measure time in
"clock ticks"; divide these values by sysconf(_SC_CLK_TCK) to
convert them  to  seconds.



Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: [FR] save command times and exit status in history automatically L A Walsh <bash@tlinx.org> - 2019-11-10 03:38 -0800

csiph-web