473,666 Members | 2,144 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exec("ntpdate <server>") doesn't work

Hi,

when I try to execute the obove mentioned to synchronise the servertime by a
php-script, it doesn't work. Other shell-commands work fine. Executing
ntpdate <server> directly in the shell works also well.
So why doesn't it work?

Thanks...
Jul 17 '05 #1
5 4332
On 2003-12-22, Thomas Brathans <th***@t-online.de> wrote:
Hi,

when I try to execute the obove mentioned to synchronise the servertime by a
php-script, it doesn't work. Other shell-commands work fine. Executing
ntpdate <server> directly in the shell works also well.


I think only root can run ntpdate. And your webserver is not running as
root, you don't want that either.

Just install an entry for ntpdate in crontab for root to run it from
time to time... man crontab for more info.
--
verum ipsum factum
Jul 17 '05 #2
Tim Van Wassenhove wrote:

I think only root can run ntpdate. And your webserver is not running as
root, you don't want that either.

Just install an entry for ntpdate in crontab for root to run it from
time to time... man crontab for more info.


No, the rights seem to be ok. For my task it is necessary, that the time is
synchronised just before a certain action in my php-script.
Any other idea?

Jul 17 '05 #3
Thomas Brathans wrote:
Tim Van Wassenhove wrote:
I think only root can run ntpdate. And your webserver is not running as
root, you don't want that either.

Just install an entry for ntpdate in crontab for root to run it from
time to time... man crontab for more info.

No, the rights seem to be ok. For my task it is necessary, that the time is
synchronised just before a certain action in my php-script.
Any other idea?

It should be mentioned that using ntpdate in this manner is an egregious
hack. If you run xntp as a daemon, and have a few stratum 2 servers to
key off of, after the daemon settles down, the current time should be
close enough for anything you need to do. This is certainly good enough
to coordinate things like radio-astronomy devices.

The idea is to have a local box act as a local timeserver, so your
webserver, DB server &etc all run xntp using that local timeserver as a
master.

Read the docs for ntpdate (which is soon to be retired). There are a
number of caveats if you need to use it. It is really intended to slew
the local clock into some kind of decent shape prior to starting the ntp
daemon. It's use to arbitrarily and asynchronously set the clock in
this manner is definitely not recommended, and may result in your clocks
*not* being in correct sync.

Jul 17 '05 #4
clvrmnky wrote:
Thomas Brathans wrote:
Tim Van Wassenhove wrote:
I think only root can run ntpdate. And your webserver is not running as
root, you don't want that either.

Just install an entry for ntpdate in crontab for root to run it from
time to time... man crontab for more info.

No, the rights seem to be ok. For my task it is necessary, that the time
is synchronised just before a certain action in my php-script.
Any other idea?

It should be mentioned that using ntpdate in this manner is an egregious
hack. If you run xntp as a daemon, and have a few stratum 2 servers to
key off of, after the daemon settles down, the current time should be
close enough for anything you need to do. This is certainly good enough
to coordinate things like radio-astronomy devices.

The idea is to have a local box act as a local timeserver, so your
webserver, DB server &etc all run xntp using that local timeserver as a
master.

Read the docs for ntpdate (which is soon to be retired). There are a
number of caveats if you need to use it. It is really intended to slew
the local clock into some kind of decent shape prior to starting the ntp
daemon. It's use to arbitrarily and asynchronously set the clock in
this manner is definitely not recommended, and may result in your clocks
*not* being in correct sync.


I was wrong - it actually was a matter of rigths, but I didn't notice it
cause some other stuff went wrong...
But I still think that my solution is a good one, cause right after
synchronising the time with ntpdate a file is timestamped... I see no other
way keeping the time between synchronisation and timestamping that short.
So nobody has the opportunity to manipulate the time before timestamping.
Jul 17 '05 #5
Thomas Brathans wrote:
clvrmnky wrote:

[...]
It should be mentioned that using ntpdate in this manner is an egregious
hack. If you run xntp as a daemon, and have a few stratum 2 servers to
key off of, after the daemon settles down, the current time should be
close enough for anything you need to do. This is certainly good enough
to coordinate things like radio-astronomy devices.

The idea is to have a local box act as a local timeserver, so your
webserver, DB server &etc all run xntp using that local timeserver as a
master.

Read the docs for ntpdate (which is soon to be retired). There are a
number of caveats if you need to use it. It is really intended to slew
the local clock into some kind of decent shape prior to starting the ntp
daemon. It's use to arbitrarily and asynchronously set the clock in
this manner is definitely not recommended, and may result in your clocks
*not* being in correct sync.

I was wrong - it actually was a matter of rigths, but I didn't notice it
cause some other stuff went wrong...
But I still think that my solution is a good one, cause right after
synchronising the time with ntpdate a file is timestamped... I see no other
way keeping the time between synchronisation and timestamping that short.
So nobody has the opportunity to manipulate the time before timestamping.


It's your design, of course, but you are not guaranteeing any further
precision on that timestamp by using ntpdate asynchronously. In fact,
you may be guaranteeing the exact opposite!

Depending on your server OS, it may be easy for non-privileged users to
change the system clock (if this is a concern, you have bigger
problems), but generally xntp run as a daemon works closely with your
hardware clock to keep it in tight precision with the stratum 2 (and
eventually, stratum 1) servers it talks to. This precision is much
tighter than a simple call to ntpdate.

AFAIK, ntpdate does not use the hardware clock drift to recalculate the
time, nor is it guaranteed to actually return the "correct" time (within
the advertised specs of ntp). It is a tool intended to slew the clock
into reasonable shape prior to running ntp. For non-critical
applications, it's probably fine. If you require a higher level of
precision or accuracy, then it is certainly not the way to go.

I'm assuming you are running a local timeserver, and your script calls
ntpdate on that server. Hitting random stratum 1 and 2 servers with
ntpdate whenever you want is a bit rude compared with running a proper
ntp server that uses a pool of stratum 2 servers to coordinate when it
synchronizes. i.e., ntp, once setup, is nice and easy on upstream servers.

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8027
by: futureofphp | last post by:
I need to access a website, Fetch the data, and then logout. Please tell me where I am wrong. I dont think its logging out properly. <? include "Snoopy.class.php"; $snoopy = new Snoopy; //Logging in $submit_url =
0
1372
by: HJ | last post by:
Hi all, I am experiencing a weird issue and I hope you can help. We are using a Microsoft Access 2003 project (.ade) with an SQL Server 2000 database. One form contains a list box with the 'Table/View/StoredProc' row source type. The row source itself is a stored procedure. When an administrator opens this form, he sees data in the list box. Profiler shows a correct command 'EXEC <stored procedure<parameters>'. That is allright.
2
5140
by: jeddiki | last post by:
Hello, I want to create my own index of websites based on my criteria rather than big G's. For example, I might like to index websites according to what they have in their "author" Meta tag ( and rejecting any site that doesn't have one). I will use this idea as a working example. Here is my suggested methodology and I would like some input on problem areas, how to make it better, etc.
0
8444
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.