Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

clock(3) [freebsd man page]

CLOCK(3)						   BSD Library Functions Manual 						  CLOCK(3)

NAME
clock -- determine processor time used LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <time.h> clock_t clock(void); DESCRIPTION
The clock() function determines the amount of processor time used since the invocation of the calling process, measured in CLOCKS_PER_SECs of a second. RETURN VALUES
The clock() function returns the amount of time used unless an error occurs, in which case the return value is -1. SEE ALSO
getrusage(2), clocks(7) STANDARDS
The clock() function conforms to ISO/IEC 9899:1990 (``ISO C90''). However, Version 2 of the Single UNIX Specification (``SUSv2'') requires CLOCKS_PER_SEC to be defined as one million. FreeBSD does not conform to this requirement; changing the value would introduce binary incom- patibility and one million is still inadequate on modern processors. BSD
June 4, 1993 BSD

Check Out this Related Man Page

CLOCK(3)						     Linux Programmer's Manual							  CLOCK(3)

NAME
clock - determine processor time SYNOPSIS
#include <time.h> clock_t clock(void); DESCRIPTION
The clock() function returns an approximation of processor time used by the program. RETURN VALUE
The value returned is the CPU time used so far as a clock_t; to get the number of seconds used, divide by CLOCKS_PER_SEC. If the processor time used is not available or its value cannot be represented, the function returns the value (clock_t) -1. CONFORMING TO
C89, C99, POSIX.1-2001. POSIX requires that CLOCKS_PER_SEC equals 1000000 independent of the actual resolution. NOTES
The C standard allows for arbitrary values at the start of the program; subtract the value returned from a call to clock() at the start of the program to get maximum portability. Note that the time can wrap around. On a 32-bit system where CLOCKS_PER_SEC equals 1000000 this function will return the same value approximately every 72 minutes. On several other implementations, the value returned by clock() also includes the times of any children whose status has been collected via wait(2) (or another wait-type call). Linux does not include the times of waited-for children in the value returned by clock(). The times(2) function, which explicitly returns (separate) information about the caller and its children, may be preferable. SEE ALSO
clock_gettime(2), getrusage(2), times(2) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2008-08-28 CLOCK(3)
Man Page

14 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

UNIX Sytem 5, release 3

Will UNIX Sytem 5, release 3 run on a Pentium (clock speed 100-200 MHz)? thanks (5 Replies)
Discussion started by: samklyle
5 Replies

2. UNIX for Dummies Questions & Answers

time clock program

How would you write a program that would continually show the time in HOURS:MINUTES on an ASCII terminal(not just xclock)? (5 Replies)
Discussion started by: Ben070371
5 Replies

3. Programming

clock() function

Hey all, i need a program to get the CPU ticks at certain points of my program. So, i thought about using the clock function, but i'm having a hard time figuring out how it really works. I wrote this simple program to try to understand it but it made me feel more confused: #include <stdio.h>... (5 Replies)
Discussion started by: kastrup_carioca
5 Replies

4. UNIX for Advanced & Expert Users

changing sys clock (PST to UTC)

Hi I'm trying to change my sys clock from PST to UTC. I've read the man date page it helpfully says :- -u, --utc, --universal print or set Coordinated Universal Time as root I have tried date --universal, date -u, date --utc, I have checked the /etc/sysinfo/clock file the... (5 Replies)
Discussion started by: OFFSIHR
5 Replies

5. Solaris

run xclock from local solaris to remote solaris

Hello - I am trying to connect to a remote solaris box from a solaris box i have locally present with me using 'ssh login@IP' ... Its connecting fine but... when I run xclock - it says 'Can't open display' Whereas, IF I connect to same remote solaris IP from my windows desktop locally via putty... (9 Replies)
Discussion started by: panchpan
9 Replies

6. Solaris

Syncing server clocks in Solaris

I have several servers with different time settings. How do I sync these servers to the same time with NTP. Thanks, Remi (5 Replies)
Discussion started by: Remi
5 Replies

7. Solaris

Unable to run xclock

Hello. I am trying to run xclock on newly built solaris box - These are the steps I followed: # DISPLAY=localhost:0.0 # export DISPLAY # xclock xclock: not found # cd /usr/openwin/bin # ./xclock Error: Can't open display: localhost:0.0 # Please suggest, what am i doing wrong? Thank... (27 Replies)
Discussion started by: panchpan
27 Replies

8. Shell Programming and Scripting

Is this the "right" way to make an alarmclock?

I'm pretty unsophisticated in my scripting. I never followed a method to learn, I just use google when I want to figure out how to use a command or preform a certain function (and most of the results are from here or the ABSG). Anyway, there are a lot of gaps in my knowledge. So, I wanted... (13 Replies)
Discussion started by: ninjaaron
13 Replies

9. Windows & DOS: Issues & Discussions

Clock doesn't tick

This is a strange one, I've never seen anything like it; the realtime clock doesn't tick while the computer's idle, only when you're watching it. Leave for 3 hours and it'll be 3 hours off. It still advances when it's off however, or the time would be far more incorrect than it is. About all... (10 Replies)
Discussion started by: Corona688
10 Replies

10. Shell Programming and Scripting

crontab+mplayer alarm clock

I'm trying to run a alarm.sh using crontab, which play a song as an alarm at 6.15 am. I'm using amixer so that volume increases by 10% in every loop. My script is the following. SHELL=/bin/bash PLAYER=/usr/bin/mplayer SONG=/home/hbar/Music/song.mp3 DISPLAY=:0.0 15 06 * * *... (10 Replies)
Discussion started by: hbar
10 Replies

11. Shell Programming and Scripting

cron: Clock generating

Hello. I would like to do this : A_VAR_FLAG = "ABCD" +------------+...................................+---------+ ...............................|.................|...................................|.............|... (7 Replies)
Discussion started by: jcdole
7 Replies

12. Programming

Simple Chess Clock

I am trying to implement a simple chess clock. It should have the following options: start, stop, reset, read. Reset will set the time to zero Start will start the clock Stop will stop the clock My problem is that I want that start continues counting the time from the time it had when it... (6 Replies)
Discussion started by: kristinu
6 Replies

13. Red Hat

Xclock command not working

Hi, I am using Xming tool to open the my RHEL machine remotely in UI mode. When I use xclock command using 'root', the command works properly and I can see the clock pop-up. However, when I run the 'xclock' command using oracle user I get an error, which is shown in the attached file. Can... (6 Replies)
Discussion started by: omniok
6 Replies

14. Solaris

Help with Reviving a NETRA240 Pls?

Hi Everybody, Hope everybody is having fun with their Solaris installations and not pulling out too much of whatever hair they have left so far. :) Just for sport, I bought an old Netra 240 used by Northern Telecom Turkish subsidiary Netas here in Turkey. My hope is to turn this into an ugly... (33 Replies)
Discussion started by: ozsavran
33 Replies