Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

how to set time in linux in that way:

1 second define as 10 seconds (10 second = 1 secods of own time)

I want fool all processes runned there to use 10x faster time. so sleep(1) will last 0.1 real seconds.

how to achieve it?

share|improve this question
3  
what is the purpose ? –  akash Jun 13 at 14:36
    
... if purpose is unknown the question is not worth answearing ... ? I want special system environment. –  user1999710 Jun 13 at 19:52
2  
@user1999710 It is often beneficial to state your ultimate goal in the question; it makes it possible to suggest alternative solutions which might be better suited to accomplishing your end goal. Otherwise, it can very easily become a XY problem question. Also consider What types of questions should I avoid asking?; particularly, "You should only ask practical, answerable questions based on actual problems that you face." While not always necessary for that, again stating the end goal often helps. –  Michael Kjörling Jun 13 at 22:14

1 Answer 1

up vote 4 down vote accepted

You can run a command (including a shell and all of its children) with an arbitrary faster clock frequency by using the warp command from the ast-open package. It uses LD_PRELOAD, so won't work with setuid or setgid or (now relatively rare) statically-linked programs. From the warp man page:

warp [ options ] date [ command [ arg ... ] ]

warp executes a dynamically linked command in a different time frame by intercepting time related system calls and modifying the times seen by command using the formula:

time' = time + warp + (time - base) * (factor - 1)

where warp is date-now, base is date by default, and factor is 1 by default.

OPTIONS

-b, --base=date

Set the base or starting date to date. Useful for repeating a set of tests. The default value is date.

-f, --factor=factor

Set the warped clock to tick at factor seconds per real second. The default value is 1.

warp executes command with optional args, or sh if command is omitted. All processes executed by command are warped in the same time frame. Time progresses for command and its children at the rate of factor times the system clock. Any files created by command or its children will appear newer than date to command and its children, but will actually be in the normal time frame for non-warped commands.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.