Is there a way to see the last time the CF service...
# cfml-general
d
Is there a way to see the last time the CF service started in cf admin, or in code? I know it shows in FusionReactor, but one app's dev box doesn't have it.
f
yes, it is possible to get the uptime from the jvm
that would be the time the service was started roughly
not the server uptime
Copy code
mf = createObject("java", "java.lang.management.ManagementFactory");
runtime = mf.getRuntimeMXBean();
writeOutput(runtime.getUptime());
a
I found this as a possible alternative: https://www.carehart.org/blog/2006/8/13/cfserver_uptime Essentially, according to this page,
#server.coldfusion.expiration#
is meant to be when your free trial expires, but, if you have a license, it just reports when the server was last restarted. In testing, it certainly lines up to when our servers were last restarted on MY server, but your mileage may vary.
d
Thanks, but that doesn't appear to line up on this dev box.
๐Ÿ‘ 1
f
wrote up a more detailed blog post on this for ya: https://www.petefreitag.com/item/998.cfm
๐Ÿ‘ 1
d
I saw that Pete, thanks. This is what I see: getStartTime(): October 11, 2022 61315 AM EDT server.coldfusion.expiration: {ts '2022-10-11 061506'} They're weirdly close, but weirdly not the same.
f
yeah, could be that your server took 2 minutes to startup that is why the server variable lags a bitโ€ฆ the jvm getStartTime would probably be most accurate
d
Hmmm, possible. I don't care down to the minute, just looking for confirmation that the data represents what we think it does. Thanks again for your insights @foundeo.
a
One more thought: you could always "create" your own start time (and other things) by using the
onServerStart()
function in
Server.cfc
(you have to set up the path to it in the cfadmin, if i recall). I have no idea whats available in Lucee but we use it all the time in CF.
๐Ÿ‘ 1