LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-29-2009, 01:40 PM   #1
mmatt
Member
 
Registered: Nov 2005
Location: UK
Distribution: archlinux
Posts: 90

Rep: Reputation: 19
Smile For Fun: Have a Unix time party


Hi there. I didn't really know where to put this exactly, just sharing with the world, looking for improvements...

You may not have realised (though you probably have) that unix time 1234567890 (seconds since the epoch) is nearly upon us. This is a small script which counts down the seconds to this event.

Code:
#!/bin/bash
# unixparty - a countdown script

secs=$[1234567890-`date +%s`]

while [ $secs -gt 0 ]
do
clear

echo
echo " Seconds until UNIX time 1234567890"
echo

secs=$[1234567890-`date +%s`]
echo "     seconds: $secs"
mins=$[$secs/60]
echo "     minutes: $mins"
hrs=$[$mins/60]
echo "     hours:   $hrs"
days=$[$hrs/24]
echo "     days:    $days"
sleep 1
done
echo
echo
echo "     HAPPY UNIX 1234567890 second!!!"
echo
echo
My question? Can anyone improve upon this since it has a number of shortfalls.
1) It scrolls using the clear command
2) The sleep mechanism isn't entirely reliable (appears to hang for ~2 secs).

I look forward to hearing your replies, though I'm sorry if you've read this and feel I've wasted your time! (It is perhaps a bit purile!)

Matt
 
Old 01-30-2009, 10:08 AM   #2
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
not sure what the significance is, but here is an improvement to your script:
Code:
clear
while [ $secs -gt 0 ]
do
   tput cup 0 0
 
Old 01-30-2009, 10:14 AM   #3
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Rep: Reputation: 42
HA! 1234567890 is on the day of my brothers birthday! He's about the most incompetent computer user there is though.
 
Old 01-31-2009, 06:57 PM   #4
mmatt
Member
 
Registered: Nov 2005
Location: UK
Distribution: archlinux
Posts: 90

Original Poster
Rep: Reputation: 19
Thanks crabboy, I'll give that a try. Planning on having it on a big screen in the lab perhaps.
 
Old 02-04-2009, 05:35 PM   #5
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
New! (slightly) Improved!

Code:
#!/bin/bash

OMG=1234567890

T=`date +%s`
if [ $T -ge $OMG ]
then
    echo "Too late."
    exit 1
fi

trap "printf \"\r\"; echo \"Awww, booo!                              \"; exit 2" SIGINT SIGHUP

S=2
while [ $S -gt 1 ]
do
    T=`date +%s`
    S=$(($OMG-$T))
    M=$(($S/60))
    H=$(($M/60))
    D=$(($H/24))
    SL=$(($S-$M*60))
    ML=$(($M-$H*60))
    HL=$(($H-$D*24))
    DL=$D
    printf "\r                                         "
    printf "\r$DL days, $HL hours, $ML minutes, $SL seconds"
    sleep 1
done

printf "\r"
echo "Wooooooooo!                              "

Last edited by ilikejam; 02-04-2009 at 05:36 PM.
 
Old 02-05-2009, 05:00 PM   #6
mmatt
Member
 
Registered: Nov 2005
Location: UK
Distribution: archlinux
Posts: 90

Original Poster
Rep: Reputation: 19
Thumbs up Thanks

Even if it was for frivilous purposes, I've learnt new and useful ways of showing output on the command line so thanks for the feedback!

Matt
 
Old 02-13-2009, 04:45 PM   #7
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Rep: Reputation: 42
Here's a countdown for ya!

http://www.1234567890day.com/
 
Old 12-11-2010, 02:49 AM   #8
JOSEPH8
LQ Newbie
 
Registered: Dec 2010
Posts: 1

Rep: Reputation: 0
Unix time is a system for describing points in time, defined as the number of seconds elapsed since midnight proleptic Coordinated Universal Time not counting leap seconds. It is used widely, not only in Unix like operating systems, but also in many other computing systems and file formats.
 
Old 12-11-2010, 11:15 AM   #9
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 547

Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by JOSEPH8 View Post
Unix time is a system for describing points in time, defined as the number of seconds elapsed since midnight proleptic Coordinated Universal Time not counting leap seconds. It is used widely, not only in Unix like operating systems, but also in many other computing systems and file formats.
What is your point? And why drag up a post that is nearly 2 years old?
 
Old 12-11-2010, 11:17 AM   #10
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by devnull10 View Post
What is your point? And why drag up a post that is nearly 2 years old?
Odds on they're about to start spamming LQ...

edit: Take a look at their signature: spam. I've reported them.
 
  


Reply

Tags
fun


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: More Fun With Security Through Obfuscation On Linux And Unix LXer Syndicated Linux News 2 06-02-2008 07:28 AM
looking for real-time-strategy and potential lan-party games oskar Linux - Games 2 03-20-2008 02:45 PM
*party* Wikipedia Reaches One Million Articles! *party* peter_89 General 1 03-01-2006 06:33 PM
It's party time (almost) explorer General 10 05-13-2004 03:07 PM
good happy fun time flynnhandley Linux - Networking 1 08-18-2003 03:27 AM


All times are GMT -5. The time now is 07:37 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration