Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

timestamp in history file

0 views
Skip to first unread message

bazzz777

unread,
Jan 26, 2002, 10:54:04 PM1/26/02
to
how can i put a timestamp on my .bash_history file?

baz

Chris F.A. Johnson

unread,
Jan 27, 2002, 12:49:35 AM1/27/02
to
On 26 Jan 2002, bazzz777 wrote:

> how can i put a timestamp on my .bash_history file?

The only way I've found is (but I haven't given it much thought):

PROMPT_COMMAND='history -s `date`' ## format `date` however you like

I don't like it, as the dates get in the way when I cursor-up.

--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2002, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License

Chris F.A. Johnson

unread,
Jan 27, 2002, 1:29:42 AM1/27/02
to
On Sun, 27 Jan 2002, Chris F.A. Johnson wrote:

> On 26 Jan 2002, bazzz777 wrote:
>
> > how can i put a timestamp on my .bash_history file?
>
> The only way I've found is (but I haven't given it much thought):

I spoke too soon.

> PROMPT_COMMAND='history -s `date`' ## format `date` however you like
>
> I don't like it, as the dates get in the way when I cursor-up.

Not only that, but it doesn't save the actual command!
Oh, well! Back to the drawing board.

bazzz777

unread,
Jan 27, 2002, 3:24:13 PM1/27/02
to
i ended up with a cron job for this,
00,30 9-23 * * * echo "$(date)---------" >> /root/.bash_history
not perfect but close enough.

baz
http://barry.hrp.com

"Chris F.A. Johnson" <c.f.a....@rogers.com> wrote in message news:<Pine.LNX.4.44.02012...@doublethink.workgroup>...

Tony Lawrence

unread,
Jan 27, 2002, 4:00:00 PM1/27/02
to
bazzz777 wrote:

> i ended up with a cron job for this,
> 00,30 9-23 * * * echo "$(date)---------" >> /root/.bash_history
> not perfect but close enough.


If the purpose is just to manually do this as the need strikes (for
example to record the start and stop of various projects), you can
simply tye

`date` (no ENTER)

and then ESC CTRL-e ENTER, which of course generates an error but does
nonetheless stamp the history file. If you don't like the error, do

echo `date` ESC CTRL-e ENTER

or use ${date} instead of `date` if you prefer.

--
Tony Lawrence
SCO/Linux Support Tips, How-To's, Tests and more: http://pcunix.com

0 new messages