8 Replies Latest reply on Mar 20, 2015 4:42 PM by ForumMigrationAdmin

    setting time with /etc/init.d/iotkit-agent script

    ForumMigrationAdmin

      You may have noticed that in the current IOT image date is set via timeapi. However, the date doesn't seem to be set correctly. With the change below it works for me (although timezone isn't taken into account):

       

      --- /tmp/iotkit-agent      2014-03-11 16:19:05.790009204 +0000 
      02 +++ /etc/init.d/iotkit-agent         2014-03-11 16:21:41.000000000 +0000 
      03 @@ -1,9 +1,9 @@ 
      04 #!/bin/sh 
      05   
      06  # update local time to UTC 
      07 -TM=$(curl -s http://www.timeapi.org/utc/now?format=%25Y.%25m.%25d-%25H:%25M) 
      08 -echo $TM 
      09 -date "${TM}" 
      10 +TM=$(curl -s http://www.timeapi.org/utc/now?format=%25Y-%25m-%25d+%25H:%25M) 
      11 +#echo $TM 
      12 +date -s "${TM}" 
      13   
      14  # start agent 
      15 NODEJS="/usr/lib/node_modules" 
      
        • 1. Re: setting time with /etc/init.d/iotkit-agent script
          ForumMigrationAdmin

          by accident I just found that /etc/init.d/udev script sets env variable TZ. Just wonder: is this the right place to set it?

          • 2. Re: setting time with /etc/init.d/iotkit-agent script
            ForumMigrationAdmin

            I'd recommend using rdate to set the time, instead of the hack in that init script. For example (probably could find a better timeserver!)

             

            rdate -s tick.greyware.com
            

             

            To set TZ i'd recommend creating /etc/localtime and either linking to the correct tzdata file from the tzdata package from iotdk.intel.com/ipk/, or just copy it from another linux box that has your correct timezone. The file you mention will export the TZ env var as whatever the /etc/localtime is, if you don't have /etc/localtime it will instead use 'UTC'.

             

            root@G:/etc/init.d# export TZ=/etc/localtime 
            2 root@G:/etc/init.d# echo $TZ 
            3 /etc/localtime 
            4 root@G:/etc/init.d# date 
            5 Wed Mar 12 18:12:01 GMT 2014 
            
            • 3. Re: setting time with /etc/init.d/iotkit-agent script
              ForumMigrationAdmin

              cool, thanks - I completely removed the time stuff from iotkit-agent and added following init script

               

              # cat > /etc/rc5.d/S99setrdate <<EOF 
              2 echo "setting date via rdate" 
              3 rdate -s time.fu-berlin.de 
              4 EOF 
              

               

              seems to work as expected

              • 4. Re: setting time with /etc/init.d/iotkit-agent script
                ForumMigrationAdmin

                ... also commented out the "sanity check" part in /etc/rcS.d/S55bootmisc.sh which killed my timezone set in /etc/localtime before as follows:

                 

                # 
                02 # This is as good a place as any for a sanity check 
                03 # 
                04 # Set the system clock from hardware clock 
                05 # If the timestamp is more recent than the current time, 
                06 # use the timestamp instead. 
                07   
                08 #test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start 
                09 #if test -e /etc/timestamp 
                10 #then 
                11 # SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M` 
                12 # read TIMESTAMP < /etc/timestamp 
                13 # if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then 
                14 #  date -u ${TIMESTAMP#????}${TIMESTAMP%????????} 
                15 #  test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop 
                16 # fi 
                17 #fi 
                

                 

                now date, time and timezone work for me

                • 5. Re: setting time with /etc/init.d/iotkit-agent script
                  ForumMigrationAdmin

                  Hi   matthias  and    brendan,

                   

                  Just want to pop in and say hi. I've been following for a few days and see the changes being made to the NTP stuff.

                   

                  Is this for the image ->  software.intel.com/sites/default/files/devkit-live-img-final.binblob.bz2 ?

                   

                  I'm DL ing it now. Being the noob that I am, it took me a little bit to find it. hehe

                   

                  The Dashboard was a little confusing to me as I want look for it but all the compilers and other tools have all weird names like a marketing guy came up to make it sound super-duper. System Studio 2014 and Studio everything else.

                   

                  Now being an OSS kind-of guy, let me try and get this right. The Yocto will bake down an embedded image to load up to what ever device you want ? And the Wind River is another tool set that sits around the Yocto to help build things like ToR Switch image that fits into the ONP framework along with all the goodies you can build into it.  Right ?

                   

                  I just want to throw all Thanks your way and to the rest of intel.  Enormous stuff here and unbelievable open door to create endless variety of solutions.

                   

                  Chris

                  • 6. Re: setting time with /etc/init.d/iotkit-agent script
                    ForumMigrationAdmin

                    Hi Chris,

                     

                    @changes for devkit-live-img-final.binblob.bz2: Yes, this thread is around the SD card image. On this image date/time doesn't seem to be set correctly. With the rdate approach I tried out and described date/time is set correctly for me and timezone is picked up form /etc/localtime which I set (ln -s) to my timezone in /usr/share/timezone (after installing tzdata as mentioned by Brendan).

                    • 7. Re: setting time with /etc/init.d/iotkit-agent script
                      ForumMigrationAdmin

                      Quote:

                       

                      Christopher M. wrote:

                       

                      Is this for the image ->  software.intel.com/sites/default/files/devkit-live-img-final.binblob.bz2 ?

                       

                      Yes, although I'd recommend you grab it form here : http://iotdk.intel.com/images/iot-devkit-201402201605-mmcblkp0.direct.bz2

                       

                      Quote:


                      Christopher M. wrote:

                       

                      The Dashboard was a little confusing to me as I want look for it but all the compilers and other tools have all weird names like a marketing guy came up to make it sound super-duper. System Studio 2014 and Studio everything else.

                       

                      Yes we're working on trying to make the dashboard a bit easier to navigate - bear with us!

                       

                      Quote:


                      Christopher M. wrote:

                       

                      Now being an OSS kind-of guy, let me try and get this right. The Yocto will bake down an embedded image to load up to what ever device you want ? And the Wind River is another tool set that sits around the Yocto to help build things like ToR Switch image that fits into the ONP framework along with all the goodies you can build into it.  Right ?

                       

                      Well right now we don't provide anything from Windriver. The aim is to do that in future releases and we demo'd the capability at MWC. Here's the way I'd put it, WR vxworks is a hard realtime OS whilst yocto allows you to build a custom linux. Here's a cute yocto linux commercial that tells the story nicely: http://vimeo.com/24743626

                       

                      Quote:


                      Christopher M. wrote:

                       

                      I just want to throw all Thanks your way and to the rest of intel.  Enormous stuff here and unbelievable open door to create endless variety of solutions.


                      Thanks for playing with our stuff!

                      • 8. Re: setting time with /etc/init.d/iotkit-agent script
                        ForumMigrationAdmin

                        playing around with the current development image (based on Yocto devkit-next on http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel-iot-devkit/) my workaround described above doesn't work any longer. As a new workaround based on rdate I use following

                         

                               # cat /etc/systemd/system/set_rdate.service 
                        02   
                        03     [Unit] 
                        04   
                        05     Description=runs rdate to set correct date/time 
                        06   
                        07     After=connman.service 
                        08   
                        09     Requires=connman.service 
                        10   
                        11        
                        12 [Service] 
                        13   
                        14     ExecStart=/bin/bash /usr/sbin/set_rdate 
                        15 [Install] 
                        16   
                        17     WantedBy=multi-user.target 
                        18   
                        19      
                        

                         

                        with

                         

                        # cat /usr/sbin/set_rdate 
                        02   
                        03 while [ 1 ]; do 
                        04   
                        05 a=$(rdate -s time.fu-berlin.de 2>&1) 
                        06   
                        07 if ! `echo ${a} | grep "bad address" 2>&1 >/dev/null`; then exit; fi 
                        08   
                        09 sleep 1 
                        10   
                        11 done 
                        

                         

                        This script will try every second to ntp sync date with in my case time.fu-berlin.de (put in whatever ntp server you prefer) until network is accessible (and hence "bad address" will not be printed) and will exit then.

                         

                        Obviously you would need to enable the service with

                         

                        systemctl enable set_rdate.service