Find the answer to your Linux question:
Results 1 to 4 of 4
hello all, my embedded system does not seem to have stime() (to set the system time) . So anybody have idea of any alternative command to stime().? C command is ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2012
    Posts
    28

    alternative command of stime()


    hello all,


    my embedded system does not seem to have stime() (to set the system time) .
    So anybody have idea of any alternative command to stime().?
    C command is preferred.


    Hoping for quick reply.

    thank you.

  2. #2
    Linux Newbie
    Join Date
    Jun 2012
    Location
    SF Bay area
    Posts
    162
    A quick check through my man pages suggests that settimeofday() would work if you have that routine. And while it's not ideal, you could also call the "date" command from C to set the time too.

  3. #3
    Just Joined!
    Join Date
    Aug 2012
    Posts
    28
    thank you for reply.

    I found 1 more alternative that is clock_settime().
    if you have any idea of it.
    can you please tel me that will it work similar to stime() ?

  4. #4
    Linux Newbie
    Join Date
    Jun 2012
    Location
    SF Bay area
    Posts
    162
    I've never needed to write code to change the clock time, so I don't have any personal experience doing what you're trying to do. But assuming you're just setting the system time infrequently, then I don't think it matters all that much which routine you use. So try one and if it works, you're all set!

    Now if you're working on a system where the clocks aren't very accurate and you're writing code to keep the time in sync with other systems, then I'd suggest looking into the possibility of running NTP instead of writing your own code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •