all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Saving emacs uptime?
@ 2024-09-26 12:37 Sharon Kimble
  2024-09-26 13:48 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sharon Kimble @ 2024-09-26 12:37 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512


Hi Folks.

How can I have emacs save its uptime to a plain text file when it closes, by my hand or if it crashes please?  

Thanks
  Sharon.
- -- 
A taste of linux = http://www.sharons.org.uk
DrugFacts = https://www.drugfacts.org.uk
Debian 12.7, Fluxbox 1.3.7, emacs 31.0.50, org 9.7.11 
-----BEGIN PGP SIGNATURE-----

iQJRBAEBCgA7FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAmb1VXYdHGJvdWRpY2Nh
c0Bza2ltYmxlMDkucGx1cy5jb20ACgkQNoGAGQr4g1txqA/+IgzobMcnljDMxxCJ
6T2BkYUbfXPU2wk3gAxtz2h1o/hk7kGB+seSHCwFfHIa+2+GiOScfIkpSPRph9Dq
iam2LaEWjoFgqhOGmAqgbaaAiFJ6PTn5t9Vb3UxR6AnzDyCujyzfn+/b7QYxrKq0
VSqVTXAFyeK8Hhm2OkYwfJ8791rt2bB8pH/x/y9Oz19X7gDVby+YJYGni2u6dD//
V+GnRTb/YJsgubTiI2yiXHyUaOELEq4C32YnxIumv00+r9pPqYYxVBNkyRH5duM9
Y20BM25q6j/0OyUggspgZVri5Uj6LSyuj8EKIOZ+nFGfMGMxFrjksgQ8I9Gcki/4
LMX6P6O4IeT/PYyOcmYMLcuIqMjdeznIUxRz8v4/cezxEsfTXz39tvZHesesgsMi
K2ldv/MH11rPQTaS1x8ynEYFOhb2qF1bDqaYxmwMJTY0D7m+0u8XZS6v9qSa5GWD
CjhQ5W9VVgfuB/Jbx1SUUgF26RuzL6vHB+YjPslV79fNJfnYNEXraoj68jjlSkyL
goJaU5i0/Ma9DubnSlBquPmOYVM8SVNMiPpZW5nVVhPlkJJTvb9sfJasBZBRmGpp
CbzKBkkr6ryGMdocjovYkCIIQOxpqWajhB8E+eR6JEobR8++uJPiyPZ2kKw77cpw
dKr6fdcqj9Uyx/jqiTkatxm0vWo=
=6rPh
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Saving emacs uptime?
  2024-09-26 12:37 Saving emacs uptime? Sharon Kimble
@ 2024-09-26 13:48 ` Eli Zaretskii
  2024-09-26 14:31 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2024-09-30 12:00 ` [Solved] " Sharon Kimble
  2 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2024-09-26 13:48 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Sharon Kimble <boudiccas@skimble09.plus.com>
> Date: Thu, 26 Sep 2024 13:37:09 +0100
> 
> How can I have emacs save its uptime to a plain text file when it closes, by my hand or if it crashes please?  

Write a kill-emacs-hook?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Saving emacs uptime?
  2024-09-26 12:37 Saving emacs uptime? Sharon Kimble
  2024-09-26 13:48 ` Eli Zaretskii
@ 2024-09-26 14:31 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2024-09-27  6:16   ` Bob Newell
  2024-09-27 11:06   ` Björn Bidar
  2024-09-30 12:00 ` [Solved] " Sharon Kimble
  2 siblings, 2 replies; 6+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-09-26 14:31 UTC (permalink / raw)
  To: help-gnu-emacs

> How can I have emacs save its uptime to a plain text file when it closes, by
> my hand or if it crashes please?  

By definition, when it crashes it can't do anything "well-defined", such
as saving its uptime to a known file.

I can see two workarounds:

- Save the uptime on a regular basis (e.g. once an hour).
- Save the uptime not from within Emacs but from a program (script?) you
  write which launches Emacs and writes the duration of the session into
  a file when the Emacs process ends.


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Saving emacs uptime?
  2024-09-26 14:31 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2024-09-27  6:16   ` Bob Newell
  2024-09-27 11:06   ` Björn Bidar
  1 sibling, 0 replies; 6+ messages in thread
From: Bob Newell @ 2024-09-27  6:16 UTC (permalink / raw)
  To: help-gnu-emacs


> - Save the uptime on a regular basis (e.g. once an hour).

If you want better resolution but don't need real precision, a
timer will let you write out the uptime say, every 5 minutes,
with minimal blocking as it would be a fast operation.  Or
even use an idle timer.  You wouldn't have to worry much about
losing a lot of information in a crash and you wouldn't even
need a kill-emacs hook.

It all depends on your use case.  If you're using this for
project tracking or billing, a 5 minute margin of error
wouldn't be all that bad.

-- 
Bob Newell
Honolulu, Hawai`i

- Via GNU-Linux/Emacs/Gnus/BBDB



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Saving emacs uptime?
  2024-09-26 14:31 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2024-09-27  6:16   ` Bob Newell
@ 2024-09-27 11:06   ` Björn Bidar
  1 sibling, 0 replies; 6+ messages in thread
From: Björn Bidar @ 2024-09-27 11:06 UTC (permalink / raw)
  To: Stefan Monnier via Users list for the GNU Emacs text editor
  Cc: Stefan Monnier

Stefan Monnier via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

>> How can I have emacs save its uptime to a plain text file when it closes, by
>> my hand or if it crashes please?  
>
> By definition, when it crashes it can't do anything "well-defined", such
> as saving its uptime to a known file.
>
> I can see two workarounds:
>
> - Save the uptime on a regular basis (e.g. once an hour).
> - Save the uptime not from within Emacs but from a program (script?) you
>   write which launches Emacs and writes the duration of the session into
>   a file when the Emacs process ends.
>
>         Stefan

Another workaround would be to use the init system to track the life
time of Emacs.
E.g. systemd tracks how long Emacs has run in general and for user
services (emacs.service).



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Solved] Re: Saving emacs uptime?
  2024-09-26 12:37 Saving emacs uptime? Sharon Kimble
  2024-09-26 13:48 ` Eli Zaretskii
  2024-09-26 14:31 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2024-09-30 12:00 ` Sharon Kimble
  2 siblings, 0 replies; 6+ messages in thread
From: Sharon Kimble @ 2024-09-30 12:00 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Sharon Kimble <boudiccas@skimble09.plus.com> writes:

> Hi Folks.
>
> How can I have emacs save its uptime to a plain text file when it closes, by my hand or if it crashes please?  
>
> Thanks
>   Sharon.

Thanks to everyone who replied, and I've found a solution from MELPA, in a package called 'uptimes' which saves my uptime every 5 minutes, and also you can show its uptimes for the last 10 restarts (default option) within emacs itself.

Thanks
  Sharon.  
- -- 
A taste of linux = http://www.sharons.org.uk
DrugFacts = https://www.drugfacts.org.uk
Debian 12.7, Fluxbox 1.3.7, emacs 31.0.50, org 9.7.11 
-----BEGIN PGP SIGNATURE-----

iQJRBAEBCgA7FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAmb6ktEdHGJvdWRpY2Nh
c0Bza2ltYmxlMDkucGx1cy5jb20ACgkQNoGAGQr4g1tWMhAAmnmMaRouhdlryWRo
57ihHVJVFtAeHWNO23ROV6ACa1Jbff2H7lWKiYgN3ERwrqbT/sXENi2eG2EzZ5D1
Jh2Rb3RUAOjDzMhJvbsYSmL6bXPp3ZKHytBlftjxYmvOe9V15NOLcOVFUTZ0LOLe
tkQ33n2JMhFtXuMC2b874bEKnCDtMxUuRxt2Y1/rdDo04FDnGcYrVFTIDX/5v3f0
21rKc1WhyrslzvNzyUuHpl+XwMjr0ysoA3jqCsspiAn/7U3xsH7dFiuoVU+9PW+Y
mOKBleZEd2/b5PTEZkaFjj/b2+8mh0Csf8H6X1omcPaADrPTEvHphWhWLLOsgK/E
WPxi2C/ZRt5hTqHGv5Iv6Ew+xY3uGnX1xi4bG1C54Q5N4+7jzRxIRBph0ms19LR2
QgSBXTYnPK90TukWPWlLyLcP3lxEec9Q9Iftm54AJi032MWlB8LxosY9xFrhMiI0
qj0ABYZ3t2V/FkWbVIVioFRPT8dlIkuSaaC5/M53XFaKXiEJRuyq5SWdnrbV9t4I
Lguc2dp+Wva/VPpX5CYm3aucdTAsH4lND0izaMh2GSpf/6YGX+PeA5ttIZGOoJk6
HGNrtyhx9rF4jge3FfBZtHee7b0hdH2h59MugGaBuA+tTWC+glddRWasdHF487K4
CTUu+nREeWKAqyZoS6k2qi3qaBw=
=eCNs
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-30 12:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 12:37 Saving emacs uptime? Sharon Kimble
2024-09-26 13:48 ` Eli Zaretskii
2024-09-26 14:31 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-09-27  6:16   ` Bob Newell
2024-09-27 11:06   ` Björn Bidar
2024-09-30 12:00 ` [Solved] " Sharon Kimble

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.