Automatic update of the clock on the iPhone - Paul Courbis


   

CAUTION !!

Please read this...



You'll fin below this text a semi-automated translation of the original website. Texts will be gradually reviewed to make them as accurate as possible but it's strongly recommanded to read the original page (preview on the right side of this text) :

Link to the original article


(if this link is broken, please go to the original website's root page and look for wanted data. Sorry about that).


Some parts of this website will never be translated to English. Part of them are user's comments that are not transfered from the French (original) version to this version. Obvously, you can leave your own comments here but they wont be transfered to the French version.

You can send comments or suggestions to the webmaster.

   
Paul Courbis


Home > Various (and summer) > Computers > Around the Iphone > Automatic update of the clock on the iPhone

Automatic update of the clock on the iPhone

Sunday 22 August 2010, by Paul Courbis

It is easy to make your iPhone syncs to a regular server ntp (Network Time Protocol) to correct the excesses of the internal clock. Here’s how ...

Prerequisites

- A jailbroken iPhone - ssh access to the iPhone (you must install the OpenSSH package in Cydia, have an ssh client on your desktop machine and connect the two on the same network) - a text file editor iPhone (vim, available on Cydia for example) or software file transfer sftp (to edit files on your PC before uploading them on the phone).

Installation

- Start by installing the software "ntpdate" available on Cydia (BigBoss source). This is a graphics software to manually adjust the clock on the iPhone but also installs the utility "ntpdate" (order online);

- Connect to your iPhone via ssh as root (default password: alpine) and create the file / var / root / ReglageHorloge containing:

#!/bin/sh DIR=/private/var/stash/Applications/NTPdate.app/bin $DIR/ntpdate ntp1.jussieu.fr - If you want to keep track of updates, you can use the following version which retain historical adjustments to the clock in / var / root / ntpdate.log: #!/bin/sh DIR=/private/var/stash/Applications/NTPdate.app/bin $DIR/ntpdate ntp1.jussieu.fr >> /var/root/ntpdate.log 2>&1 - Make this script executable with the command:

chmod a+x  /var/root/ReglageHorloge - At this point you can test its operation by typing the command line: /var/root/ReglageHorloge - Create the file / Library / LaunchDaemons / paul.courbis.horloge.plist containing: Label paul.courbis.horloge ProgramArguments /var/root/ReglageHorloge StartCalendarInterval Minute 0 Label paul.courbis.horloge ProgramArguments /var/root/ReglageHorloge StartCalendarInterval Minute 0 Label paul.courbis.horloge ProgramArguments /var/root/ReglageHorloge StartCalendarInterval Minute 0 Label paul.courbis.horloge ProgramArguments /var/root/ReglageHorloge StartCalendarInterval Minute 0 Label paul.courbis.horloge ProgramArguments /var/root/ReglageHorloge StartCalendarInterval Minute 0 Label paul.courbis.horloge ProgramArguments /var/root/ReglageHorloge StartCalendarInterval Minute 0 Label paul.courbis.horloge ProgramArguments /var/root/ReglageHorloge StartCalendarInterval Minute 0

WARNING: It appears that some browsers (like Chrome) sometimes display incorrectly above code by failing to display some tags. The text "paul.courbis.horloge" doir be framed by opening and closing tags of "string" is <string> paul.courbis.horloge </ string>.

- Enable this scheduled task by the command (one line)
launchctl load /Library/LaunchDaemons/paul.courbis.horloge.plist

Now your iPhone will connect every hour (on the hour) to synchronize the clock with the ntp server Jussieu ....

You can change the frequency of this update by modifying the block: Minute 0 Minute 0

For example by replacing Hour 7 Minute 30 Hour 7 Minute 30 Hour 7 Minute 30 Hour 7 Minute 30

To connect every morning at 7:30 minutes.

Or Hour 7 Minute 30 Hour 19 Minute 30 Hour 7 Minute 30 Hour 19 Minute 30 Hour 7 Minute 30 Hour 19 Minute 30 Hour 7 Minute 30 Hour 19 Minute 30 Hour 7 Minute 30 Hour 19 Minute 30 Hour 7 Minute 30 Hour 19 Minute 30 Hour 7 Minute 30 Hour 19 Minute 30 Hour 7 Minute 30 Hour 19 Minute 30 To synchronize the morning at 7:30 ET in the evening at 7:30 p.m. ...

Notes: - if modified plist file, run the command:
launchctl unload

/ Library / LaunchDaemons / paul.courbis.horloge.plist
before recharging the job by:
launchctl load /Library/LaunchDaemons/paul.courbis.horloge.plist

- Depending on the version of IOS, the path to the command ntpdate may vary. The easiest way is to install the command locate (in the package "Find utilities") to update its database using the command updatedb then find the command ntpdate by typing locate ntpdate .

1 Message

  • Automatic update of the clock on the iPhone 24 September 2011 19:40, by Hendrik

    The above is much easier without the shell script. Just create a .plist file (see the original article) but change the following:

    under <key>ProgramArguments</key> put
    <array>
    <string>/private/var/stash/Applications/NTPdate.app/bin/ntpdate</string>
    <string>time.fu-berlin.de</string>
    </array>

    The first <string> argument is the command you want to run the second is the parameter being used (in our case the time server you want to synchronise with).

    If you want logging, add the following:

    <key>StandardErrorPath</key>
    <string>/var/root/ntperror.log</string>
    <key>StandardOutPath</key>
    <string>/var/root/ntpout.log</string>

    Instead of specifying a time to run, you can set an interval:
    Remove the <key>StartCalenderInterval</key> section and add the following:

    <key>StartInterval</key>
    <integer>3600</integer>

    3600 means this will run every 3600 seconds (= 1 hour).

    You can also set

    <key>RunAtLoad</key>
    <true/>

    which means (if I understood correctly) the program will be run when you boot your iphone. I am not sure if this will actually work because your phone might not be connected to the internet at the time this job is first run. alternatively you could create a second plist file with a different Label and an interval of maybe 120 seconds that is set to only run once with:
    <key>LaunchOnlyOnce</key>
    <true/>
    so that the job is run once on boot but with a delay of XXX seconds. (Don’t use RunAtLoad in the second script)

    For further references look at the man page for launchd.plist
    http://developer.apple.com/library/...

    Cheers

    Hendrik

    repondre message

Comment on this article