You are not logged in.

#1 2009-05-23 05:52:21

arew264
Member
From: Friendswood, Texas, US
Registered: 2006-07-01
Posts: 394
Website

[SOLVED] Command Line Clock

I remember seeing a forum topic a while back where someone posted a command to give a clock at the command line that would update every second and whatnot, but I can't seem to find the topic. IIRC, it was just `watch` and a command that actually rendered the current time (it wasn't `date`). I can't seem to find the command by searching through man pages, so hopefully someone knows what I'm talking about?

Last edited by arew264 (2009-05-23 14:53:30)

Offline

#2 2009-05-23 06:32:10

keenerd
Package Maintainer (PM)
Registered: 2007-02-22
Posts: 647
Website

Re: [SOLVED] Command Line Clock

Not what you are looking for, but the most awesome CLI clock is clockywock

Last edited by keenerd (2009-05-23 06:32:31)

Offline

#3 2009-05-23 12:09:23

djnm
Member
From: USA
Registered: 2008-12-21
Posts: 78

Re: [SOLVED] Command Line Clock

Maybe http://bbs.archlinux.org/viewtopic.php?id=68663 is what you were looking for?


br0tat0chip in #archlinux and on freenode

Offline

#4 2009-05-23 13:18:45

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Command Line Clock

while true
do
  time=`date +%r`
  printf "\r${time}"
done

It's a clock.

Offline

#5 2009-05-23 14:53:12

arew264
Member
From: Friendswood, Texas, US
Registered: 2006-07-01
Posts: 394
Website

Re: [SOLVED] Command Line Clock

@keenerd
That's definitely awesome, but I'm looking for a digital clock because I can put a digital clock in a small window at one of the corners of the screen.

@djnm
That's the thread I was looking for. Thanks.

@karol
Yep, it's a clock. I'll have to figure out whether I want to use a straight clock like you wrote or use figlet like the poster in the forum topic. Beyond that, the approach is basically the same.

Offline

#6 2009-05-23 21:57:40

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: [SOLVED] Command Line Clock

karol wrote:
while true
do
  time=`date +%r`
  printf "\r${time}"
done

It's a clock.

This produces a high cpu load. Insert a sleep 1 in the loop. Same result, almost no extra load. tongue


To know or not to know ...
... the questions remain forever.

Offline

#7 2009-05-23 22:29:33

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Command Line Clock

> This produces a high cpu load. Insert a sleep 1 in the loop. Same result, almost no extra load.
Ooops, shame on me. Thanks for the heads up, bernarcher.

Offline

#8 2009-05-23 23:03:46

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Re: [SOLVED] Command Line Clock

Improved.  Run with an ampersand following, and it will give you the time as you work.

#!/bin/bash

### Floating Clock ###
######################

cols=`tput cols`

touch /tmp/tclock.run
while [ -e /tmp/tclock.run ]; do
  tput sc
  tput cup 0 $((cols - 13))
  printf " $(date +%r) "
  tput rc
  sleep 1
done

Last edited by Wintervenom (2009-05-23 23:04:20)

Offline

#9 2009-05-23 23:07:58

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: [SOLVED] Command Line Clock

Just to show off how boring I am:

watch -n 1 -t date

Offline

#10 2009-05-23 23:43:02

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Command Line Clock

C'mon, you're not boring and the code is p-e-r-f-e-c-t.
May I have your autograph?

Offline

#11 2009-05-24 18:37:20

Knute
Member
From: Minot, ND
Registered: 2009-03-17
Posts: 604

Re: [SOLVED] Command Line Clock

If you want a digital clock that is low on resources to run in X, then i would suggest an app/package called asimpleclock.  It's an adesklet, and is very easy to configure.


Knute

Offline

#12 2009-05-24 18:57:07

Ghost1227
Forum Fellow
From: Omaha, NE, USA
Registered: 2008-04-21
Posts: 1,422
Website

Re: [SOLVED] Command Line Clock

Another cli option is tty-clock...


.:[My Blog] || [My GitHub]:.

Offline

#13 2009-05-24 20:06:24

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: [SOLVED] Command Line Clock

skottish wrote:

Just to show off how boring I am:

watch -n 1 -t date

Woaah! That's perfect. big_smile
How can it be that this watch command slipped my attention in ten years of unix/linux use???

Thanks, scottish!


To know or not to know ...
... the questions remain forever.

Offline

#14 2009-05-25 01:16:24

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: [SOLVED] Command Line Clock

You're welcome. watch is really useful. I use it to monitor things like sensors from lm_sensors when I'm being particularly brutal on my processor.

Offline

Board footer

Powered by FluxBB