function::local_clock_us - Linux


local_clock_us is a system call that retrieves the current time in microseconds since epoch. It is intended to be used for precise timing and synchronization tasks in user-space applications.


long local_clock_us(void);

Return Value

On success, it returns the current time in microseconds since epoch. On error, it returns -1 and sets errno to indicate the error.


This command does not take any options or flags.


Get the current time in microseconds:

#include <time.h>
#include <stdio.h>

int main() {
  long microseconds = local_clock_us();
  printf("Current time in microseconds since epoch: %ld\n", microseconds);
  return 0;

Common Issues

  • Incorrect usage: Ensure that the command is called correctly without any syntax errors.

  • Insufficient permissions: The user running the command must have appropriate permissions to access the system time.

  • Unsupported platform: This system call is not available on all platforms. Refer to the system documentation for availability information.


local_clock_us can be combined with other timing functions, such as gettimeofday and clock_gettime, to achieve high-precision timing and synchronization in custom applications.

Related Commands

  • gettimeofday
  • clock_gettime
  • clock