LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-14-2006, 11:28 PM   #1
vskgopu
LQ Newbie
 
Registered: May 2006
Posts: 17

Rep: Reputation: 0
How to find the time in unix ?


Hi friends,

I want to get the time, but i dont want to use the system time..coz somebody may change it.

I am implementing a SMTP relay server to delay the mails for some "x"-minutes. so that i have to check the time. In this place i cant use the systme time,coz as i said somebody can change it.
Is there any other clock in unix..machines..runnning uniquely..regardless of the system time?

Note : I dont want to get the exact time. I just want a clock to find the delay time.


Plz help me...
Thanks in advance....
 
Old 05-14-2006, 11:46 PM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
usleep?
http://www.die.net/doc/linux/man/man3/usleep.3.html

or sleep(1)
Code:
SLEEP(1)                                     User Commands                                     SLEEP(1)

NAME
       sleep - delay for a specified amount of time

SYNOPSIS
       sleep NUMBER[SUFFIX]...
       sleep OPTION

DESCRIPTION
       Pause for NUMBER seconds.  SUFFIX may be s for seconds (the default), m for minutes, h for
       hours or d for days.  Unlike most implementations that require NUMBER be an integer, here NUM‐
       BER may be an arbitrary floating point number.

       --help display this help and exit

       --version
              output version information and exit

AUTHOR
       Written by Jim Meyering and Paul Eggert.

Last edited by Simon Bridge; 05-14-2006 at 11:50 PM.
 
Old 05-15-2006, 03:36 AM   #3
vskgopu
LQ Newbie
 
Registered: May 2006
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks friend i got the solution by using the 'times' call it gives the number of ticks elapsed since the system has been up..
Any how thanks a lot..
 
Old 05-15-2006, 06:11 AM   #4
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Any PC, regardless of the operating system, always maintains it's own time on a hardware clock.
Unfortunately, those clocks are known to be inaccurate and -as you already pointed out yourself- the users
can alter the time/date.

If you want to get the universally correct time, you should consider setting up NTP to retrieve
the exact time from a world-wide server.

Likewise, once you got one machine that queries those servers, you can setup your other machines to contact your first machine, thus "propagating" the correct time accross your machines.

Have a look at:
man ntpd
 
Old 05-15-2006, 06:36 AM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
Quote:
Originally Posted by vskgopu

I want to get the time, but i dont want to use the system time..coz somebody may change it.
Only root can change it.
 
Old 05-15-2006, 08:48 AM   #6
vskgopu
LQ Newbie
 
Registered: May 2006
Posts: 17

Original Poster
Rep: Reputation: 0
thanks friends
 
Old 05-16-2006, 03:03 AM   #7
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
You're welcome.
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux/Unix Command to find RAM size? ssnkumar Linux - General 9 09-09-2009 10:38 AM
LXer: Advanced techniques for using the UNIX find command LXer Syndicated Linux News 0 05-04-2006 05:21 AM
Is there a good part time Unix Course in London? martinj Other *NIX 5 07-19-2005 01:50 PM
Which is best to install for a first time Linux user with NO UNIX knowledge or LINUX? chris24ang Linux - Newbie 13 05-16-2004 11:44 AM
unix time chrismiceli Linux - General 1 01-07-2003 11:13 PM


All times are GMT -5. The time now is 08:57 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration