Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to log PC uptime. How I can do this?

I use uptime for this and I will when ubuntu is shutdown write this command output in a file.

share|improve this question
have you tried steps which i posted –  Rahul Patil Dec 26 '12 at 10:13
@RahulPatil Thanks. Yes, i tested it and works fine :). Thanks –  chalist Dec 26 '12 at 11:12

1 Answer 1

up vote 1 down vote accepted

If you are using Ubuntu

then add below lines in "/etc/rc0.d/S60umountroot" at the beginning.

echo "$(date) $(/usr/bin/uptime)" >> "${Log}"

or you can simply use logger

logger "UPTIME: $(uptime)"

then it will gives details in /var/log/syslog or /var/log/messages

Note :- Please careful edit this file

If you are using CentOs, then do the same in "/etc/rc.d/rc0.d/S01halt", but note that it should be added in beginning of the file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.