Click to See Complete Forum and Search --> : Log uptime
jsundquist
04-26-2003, 05:11 PM
I am looking for a script or a program that will write out to a file the current up time and to also figure out what the longest uptime of my computer has been. I have not yet been able to find anything. I searched the board here and I didnt seem much of anything of what I was looking for. Anyone know something that might help me out? I currently have something running on my windows computer. This is what it looks like
joesbox
04-26-2003, 06:52 PM
if you are familiar with perl or some other lanuage then you can write a simple script that will make the uptime call and write it to a log that you create. then you can also have it do a comparison to read the seperate uptimes and show the longest uptime.
bwkaz
04-26-2003, 07:54 PM
You could parse the output of last | grep reboot, too, assuming /var/log/wtmp exists.
inkedmn
04-26-2003, 11:21 PM
>>> import os
>>> up = os.popen("uptime").read()
>>> print up.split()
try that in python, that'll give you a good start...
[edit]
didn't realize you were using windows, ignore ^^ that :)
jsundquist
04-27-2003, 01:17 AM
Ok first off. I dont really know any programming languages too well other then VB, Basic, VB Script, some JavaScript, and very little Java. With that said. Anyone with actual working code that I could just throw in?
Sepero
04-27-2003, 05:08 AM
Put this in your shutdown script, somewhere before the "killall" command:/usr/bin/uptime >> <file>
jsundquist
04-27-2003, 10:29 AM
Originally posted by Sepero
Put this in your shutdown script, somewhere before the "killall" command:/usr/bin/uptime >> <file>
Where is the shutdown script usually located?
joesbox
04-27-2003, 10:31 AM
dude if you are using windows then why try. get a linux and try learning a language that will work with more than one browser. java is good but from what i hear it is buggy and java script is just for web use. vb...... why. it was created by the beast for the beast and only for the beast. try c/c++ or python or perl or i don't know... something else.
jsundquist
04-27-2003, 10:53 AM
Originally posted by JOES_BOX
dude if you are using windows then why try. get a linux and try learning a language that will work with more than one browser. java is good but from what i hear it is buggy and java script is just for web use. vb...... why. it was created by the beast for the beast and only for the beast. try c/c++ or python or perl or i don't know... something else.
I was only stating some languages that I already knew. I dont know c, python, or perl yet but I now plan on learning some since I am going to be running 2 linux boxes in my house. As I learn linux I plan to learn some of the languages its just going to take some time.
joesbox
04-27-2003, 11:08 AM
i am sorry for the flame. it is only 11 am and i have started off having a bad day and i know that i am going to have a bad day at work kids started my day off with screams and whinning and yesterday at work i was reading some scary forecasting of what M$ is going to be doing with the new version of hell released.
if you like i can write something quick that might tide you over but it may take me a few days. i am really busy and at home i don't have much time to code. if you are going to learn a code then i would either learn perl or python. i have heard that python is really easy to learn but i don't know i only know javascript and perl. i plan on learning c/c++ but i just can't find the time. anyway if you are planning on learning perl then i suggest picking up the book "CGI and PERL for the world wide web" (http://www.amazon.com/exec/obidos/tg/detail/-/020135358X/qid=1051455901/sr=1-4/ref=sr_1_4/103-1281613-4057413?v=glance&s=books)
this is what i learned off of and now i can figure out anything. well almost. lol
again sorry for the flame dude.... amends??
:)
jsundquist
04-27-2003, 11:25 AM
Yeah were cool. Don't worry about it. We all have our good days a bad days. I perfectly undrstand. I myself just got up not too long ago.
If you would like to take on a project like this that would be great. I cant seem to find something like this anywhere. I mean even if its just something that scanns through a log file for the longest, shortest, current, and total uptime. Thats all I am looking for. I was thinking it would look something like this
[jon@Mandrake jon]$ uptimelog
Longest uptime: 2 Days 12:09
Shortest uptime: 3:02
Current uptime: 2 Days 12:09
Total uptime: 5 Days 5:56
[jon@Mandrake jon]$
Thats what I thought it would or code look like
iDxMan
04-27-2003, 01:03 PM
..or if you're online for the majority of the time [read: cable/dsl] you could use one of the uptimes projects. http://uptimes.wonko.com , http://uptimes.nu
-r
Sepero
04-27-2003, 06:53 PM
Every distro of Linux has a little bit different startup and shutdown scripts. You can find out about your startup scripts by following the link below. After learning about your startup scripts, you'll understand your shutdown scripts a lot better.
http://www.tldp.org/HOWTO/From-PowerUp-To-Bash-Prompt-HOWTO.html
P.S.
Those scripts are probably in a folder named something like "/etc/rc.d/rc.6"
joesbox
05-02-2003, 08:43 PM
just an update for you jsundquist.
i haven't forgotten about the program. i am making it as we post. it is just a little bigger than i thought. don't worry.
apeekaboo
05-03-2003, 03:42 AM
If you want a simple util to keep track of your uptimes I suggest you try uptimed (http://freshmeat.net/projects/uptimed/?topic_id=136).
If not writing your own util is part of the project, that is... :)
joesbox
05-03-2003, 10:04 AM
well i am trying to keep myself up and up on perl as i don't have any other projects that i am working on for work. so i am doing little things like my screenshot project. nothing special but got me to think a little.
jsundquist
05-03-2003, 10:15 AM
Originally posted by apeekaboo
If you want a simple util to keep track of your uptimes I suggest you try uptimed (http://freshmeat.net/projects/uptimed/?topic_id=136).
If not writing your own util is part of the project, that is... :)
Hmmm something like that might almost work.
Originally posted by JOES_BOX
just an update for you jsundquist.
i haven't forgotten about the program. i am making it as we post. it is just a little bigger than i thought. don't worry.
Sounds good. I havent got my nice daily update from justlinux that people posted to this topic for a while so I almost lost it. Dont worry how long it takes. Im not in too much of a rush.