Trying to change realtime clock in Ubuntu 14.04 in C++ application, getting "Operation not permitted"
NickName:Otto Nahmee Ask DateTime:2016-11-15T23:30:13

Trying to change realtime clock in Ubuntu 14.04 in C++ application, getting "Operation not permitted"

OS: Ubuntu

Version: 14.04

Language: C++11

I've written an application that needs to change the real-time clock based on different sources. As background, the reason that I'm not using NTP to manage this is based on different clock sources that are needed at different points, for all the current applications using CLOCK_REALTIME. This application receives a clock reference time and sets the clock using clock_settime. This returns the message Operation not permitted.

if(clock_settime(CLOCK_REALTIME, &timeRT) != 0) { std::cerr << " Set clock_settime(CLOCK_REALTIME, &timeRT) = " << strerror(errno) << std::endl; }

I presume the applications privileges are not set correctly.

  • Any direction on how to do this?
  • Anything else I should check?

Copyright Notice:Content Author:「Otto Nahmee」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/40613716/trying-to-change-realtime-clock-in-ubuntu-14-04-in-c-application-getting-ope

More about “Trying to change realtime clock in Ubuntu 14.04 in C++ application, getting "Operation not permitted"” related questions

Trying to change realtime clock in Ubuntu 14.04 in C++ application, getting "Operation not permitted"

OS: Ubuntu Version: 14.04 Language: C++11 I've written an application that needs to change the real-time clock based on different sources. As background, the reason that I'm not using NTP to ma...

Show Detail

gcc: CLOCK_REALTIME is undeclared

I was trying to run the C code that I found on this website #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;time.h&gt; #define n 2048 double A[n][n]; double B[n][n]; double C[n]

Show Detail

gcc: CLOCK_REALTIME is undeclared

I was trying to run the C code that I found on this website #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;time.h&gt; #define n 2048 double A[n][n]; double B[n][n]; double C[n]

Show Detail

usleep with clock_gettime() issue

I was doing a microbenchmark. My code appears something like this while(some condition){ struct timespec tps, tpe; clock_gettime(CLOCK_REALTIME, &amp;tps); encrypt_data(some_data)

Show Detail

CLOCK_REALTIME nanosecond precision support in kernel

I wrote a simple program to determine if i can get nanosecond precision on my system, which is a RHEL 5.5 VM (kernel 2.6.18-194). // cc -g -Wall ntime.c -o ntime -lrt #include &lt;inttypes.h&gt; #

Show Detail

AWS EC2 Ubuntu 14.04 instance clock running 12 minutes ahead

We are using Ubuntu 14.04 (LTS) on Amazon EC2 m4.xlarge instances. It seems the instance clock is running 12 minutes ahead of the current time. I am using python shell to check time by running this

Show Detail

What is the use of CLOCK_REALTIME?

I am reading about the difference between CLOCK_REALTIME and CLOCK_MONOTONIC Difference between CLOCK_REALTIME and CLOCK_MONOTONIC? The CLOCK_REALTIME has discontinuities in time, can jump forwar...

Show Detail

nanoseconds from clock_gettime() on mips router

I am trying to get nanosecond resolution from CLOCK_REALTIME on a 1GHz MIPS router. When I compile the below code for x86 and run on a 1GHz vm, I get nanosecond resolution. When I compile for mips ...

Show Detail

Key error trying to run basic ubuntu image

I'm trying to run a basic image as described in the Docker tutorial:- docker --version Docker version 1.9.0, build 76d6bc9 docker run -t -i ubuntu:14.04 /bin/bash but it is reporting: Error while

Show Detail

Timing skew with clock_gettime and struct stat.mtim

The following C program first gets the time using clock_gettime(), and then creates a file and reads out its modification time. On my system at least, the file mtime is an older timestamp than the

Show Detail