spookiepower
Posts: 3
Joined: Sat May 18, 2019 6:59 pm

How to see how many hours my RP is running ?

Sat May 18, 2019 7:48 pm

I have my RP connected to a Powerbank, but wonder how many hours it can stay on this way. Is there some kind of logfile I can look into, to see when it was turned on and when it did shotdown/ran out of power ?

User avatar
B.Goode
Posts: 7868
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: How to see how many hours my RP is running ?

Sat May 18, 2019 8:18 pm

spookiepower wrote:
Sat May 18, 2019 7:48 pm
I have my RP connected to a Powerbank, but wonder how many hours it can stay on this way. Is there some kind of logfile I can look into, to see when it was turned on and when it did shotdown/ran out of power ?

To answer the question in the title, see replies in this forum thread: https://www.raspberrypi.org/forums/view ... 0#p1461960

And yes, there are loads of logfiles...

Have a look in /var/log for files like syslog and messages.

klricks
Posts: 6440
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: How to see how many hours my RP is running ?

Sat May 18, 2019 8:21 pm

spookiepower wrote:
Sat May 18, 2019 7:48 pm
I have my RP connected to a Powerbank, but wonder how many hours it can stay on this way. Is there some kind of logfile I can look into, to see when it was turned on and when it did shotdown/ran out of power ?
To show how long since last power-on or reboot:

Code: Select all

uptime
Of course nothing is logged on improper shutdown.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

LTolledo
Posts: 1538
Joined: Sat Mar 17, 2018 7:29 am

Re: How to see how many hours my RP is running ?

Sat May 18, 2019 9:13 pm

you can also use

Code: Select all

htop
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

dl324
Posts: 118
Joined: Mon May 06, 2019 7:33 pm
Location: Pacific Northwest, USA

Re: How to see how many hours my RP is running ?

Sun May 19, 2019 1:46 am

spookiepower wrote:
Sat May 18, 2019 7:48 pm
is there some kind of logfile I can look into, to see when it was turned on and when it did shotdown/ran out of power ?
What I do is put commands in crontab to echo the reboot time to a file.

To monitor how long it ran before shutting down, you can put commands to echo the current time to a file. How frequently depends on the resolution you want. I've done it with 4 hour intervals.

Code: Select all

@reboot sleep 60; echo REBOOT `date` >> uptime.log
0 0 * * * echo `date` >> uptime.log
0 */4 * * * uptime >> uptime.log
The sleep is to let the OS set the correct time.

spookiepower
Posts: 3
Joined: Sat May 18, 2019 6:59 pm

Re: How to see how many hours my RP is running ?

Sun May 19, 2019 1:25 pm

Thanks for your answers :)

Return to “Beginners”