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 am using CentOS 5.6, is there a way to view a "live" time, without constantly executing the date command?

Constantly excuting the date command can be quite frustrating and repetitive when checking the time for running cron jobs.

share|improve this question
    
Do you want the cron jobs to check the time? or do you just want to know the time in your shell somehow? for the latter you could change your PS1 to include this information. Off course that only displays the new time every time PS1 is "called" or "displayed" whatever the correct term is. –  Bram Jun 8 '12 at 12:32
    
No, I don't want the cron jobs to check the time. I was looking for a utility that would allow me to view the time live in the way that I could run a command and it would run until I quit it, similar to tail but for the current system time. –  crmpicco Jun 8 '12 at 12:51
1  
Are you looking for something like watch -n 1 date? –  Ulrich Dangel Jun 8 '12 at 14:08
    
@UlrichDangel That's exactly what i'm looking for. Many thanks. I'm more than happy to accept that as the answer if you would like to update. –  crmpicco Jun 8 '12 at 15:39
add comment

2 Answers

up vote 4 down vote accepted

If you want to periodically execute a specific command you can use watch (1). Per default the specified program is executed every two seconnds.

To run date every second just run:

watch -n 1 date
share|improve this answer
add comment

When using GNU Screen, I set my hardline to include the current system time and date.Screenshot Example

This is an excerpt from my screenrc:

hardstatus alwayslastline
hardstatus string '%{= Bk} %{c}[ %{y}%H %{c} ][%= %{=kw}%?%-Lw%?%{g}(%{W}%n*%f%t%?(%u)%?%{g})%{y}%?%+Lw%?%?%= %{g}][%{Y}%Y-%m-%d %{W}%c %{g}]'

The relavant part is the %{Y}%Y-%m-%d %{W}%c %{g}

share|improve this answer
    
I have a CentOS 5.6 VM running on my Windows 7 machine and I am accessing it via SSH using PuTTY. Is it possible to display this through PuTTY? –  crmpicco Jun 8 '12 at 12:50
    
The screen shot above is from my Win7 workstation and the terminal displayed is in fact PuTTY. So 100% yes. –  Tim Jun 8 '12 at 12:58
1  
If screen is not installed it should be in the standard CentOS yum repo: yum install screen –  Tim Jun 8 '12 at 13:00
    
I didn't have screen installed, so i've just installed it. In my /etc/screenrc I have the following line: # Red Hat's normal status line hardstatus string "[screen %n%?: %t%?] %h" However, PuTTY doesn't show this right now for me. Is there a setting to display it? –  crmpicco Jun 8 '12 at 13:09
    
After tweaking your screenrc, did you run screen itself? From a normal shell just run screen. –  Tim Jun 8 '12 at 13:31
add comment

Your Answer

 
discard

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.