- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Display time which loops?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:08 AM
10-14-2002 03:08 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:10 AM
10-14-2002 03:10 AM
Re: Display time which loops?
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:20 AM
10-14-2002 03:20 AM
Re: Display time which loops?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:36 AM
10-14-2002 03:36 AM
Re: Display time which loops?
#
while [ "1" = "1" ]; do
sleep 15
date
done
Change the sleep 15 to your desired sleep time.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:49 AM
10-14-2002 03:49 AM
Re: Display time which loops?
Base on the output i get:
(i change sleep 1)
Mon Oct 14 19:28:35 SST 2002
Mon Oct 14 19:28:36 SST 2002
Mon Oct 14 19:28:27 SST 2002
Is it possible if my time looks like this:
Previous
--------
19:28:01
Current
--------
19:28:02 (1 is replace by 2 - the cursor is at 2)
I do not want it to go to the next line. If i keep refresh the screen, will it increase the uptime and slow down my application.
Can i refresh only a portion of a screen rather than the whole screen.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:56 AM
10-14-2002 03:56 AM
Re: Display time which loops?
#!/usr/bin/sh
# Show time of day
while :
do
date
sleep 1
done
---
This shows the timer/date every second. Probably not what you want. You most likely want it to appear in some corner of your display, sort of like Windows. This is where tput will come in handy:
#!/usr/bin/sh
# Show time of day in upper right corner
set -u
PATH=/usr/bin
UR=$(tput cup 0 60)
while :
do
# various date/time formats, last one wins
MYDATE=$(date '+%R')
MYDATE=$(date '+%a %R')
MYDATE=$(date)
LEN=${#MYDATE}
START=$((COLUMNS-LEN-2))
UR=$(tput cup 1 $START)
echo "$UR$(tput bold) $MYDATE $(tput sgr0)"
sleep 1
done
---
Now this script allows you to change the date format (3 examples are shown) and it will calculate how to position the string on the screen. I've added the bold enhancement to make the string stand out.
This is a bit impractical since when you run it, the time/date is show OK but you can't do anything except watch the script run. If you put it in the background, it will fail because a background process is trying to write to an active terminal.
What you want is very complicated for a standard terminal. Each time you run vi or other programs, this date program will mess up the screen. And just listing files in the shell will scroll the upper right corner off the top of the screen. But it does demonstrate how you can use tput and the Curses library.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:57 AM
10-14-2002 03:57 AM
Re: Display time which loops?
Try this:
============================
#!/bin/sh
while :;do
echo `date "+%H:%M:%S"` '\b\b\b\b\b\b\b\b\b\c'
sleep 1
done
=============================
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 04:40 AM
10-14-2002 04:40 AM
Re: Display time which loops?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 05:10 AM
10-14-2002 05:10 AM
Re: Display time which loops?
if [[ "$-" = *i* && ( "$TERM" = hp* || "$TERM" = *2392* ) ]]; then
while sleep 1; do
clock=$(/usr/bin/date "+%H:%M:%S")
echo "\033&f0a8k8d0L$clock\c"
echo "\033&jB\c"
done &
fi
This writes the time to the
Regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 07:15 AM
10-14-2002 07:15 AM
Re: Display time which loops?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 07:29 AM
10-14-2002 07:29 AM
Re: Display time which loops?
Regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 07:32 AM
10-14-2002 07:32 AM
Re: Display time which loops?
while [ $loop = 1 ]
do
clear
date | awk '{print $4}'
sleep 1
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 07:40 AM
10-14-2002 07:40 AM
Re: Display time which loops?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 07:50 AM
10-14-2002 07:50 AM
Re: Display time which loops?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 01:13 AM
10-18-2002 01:13 AM