Showing a running clock in a linux shell

I was working with a scheduler and wanted to keep track of my server time. Continuous invocation of date command wouldn’t cut it. So a little search on net lead me to this link which basically sums up the following script. This script will show the current time on the top left corner of your terminal which is good enough for my usecase.


while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-11));echo -e "\e[31m`date +%r`\e[39m";tput rc;done &

I executed this code on a Cent OS system and it worked fine. I have tested this snippet in Debian as well and it worked like a charm. This won’t solve everybody’s problem but for specific situation where you just want to watch the clock of your server from a shell this is a good enough script.

One thought on “Showing a running clock in a linux shell

  1. Pingback: Using tput to label tmux panes | Thoughts of Abhinav Anand

Leave a Reply

Your email address will not be published. Required fields are marked *