# Getting started

This path builds `jetlag` from source, starts a program with its clock 30 days ahead, and then puts the clock back to real time while the program keeps running. Jetlag has no published release yet, so you build it.

You need Linux on x86-64, `git` and [devenv](https://devenv.sh). The first dev shell downloads epochd, which Jetlag builds on, so it needs network access that time. You do not need root.

The first success is a running program that prints a date 30 days from now, then today's date again, without a restart.

## Build Jetlag

Clone the repository:

```
git clone https://gitlab.techtailors.net/slopkit/jetlag.git
cd jetlag
```

Enter the dev shell and build:

```
devenv shell
go build -o bin/jetlag ./cmd/jetlag
```

The dev shell prints this line when it is ready. `go build` prints nothing when it succeeds.

```
slopkit/jetlag dev shell
```

Jetlag builds against epochd v0.8.1 plus three patches kept in `patches/epochd/`. The dev shell applies them into `third_party/epochd` when you enter it.

Unverified: the epochd download on the first dev shell. It was checked from a local copy of the epochd module with the network turned off, not from `github.com`.

## Start a program 30 days ahead

Stay in the dev shell, in the repository root.

1. Print the date, then print it again through Jetlag.

```
date -u
bin/jetlag run --offset 30d -- date -u
```

`jetlag run` starts the command with its clock already shifted. It needs no privilege. Your dates will differ. The second one is 30 days after the first, and the line that starts with `jetlag:` goes to stderr.

```
Fri Dec  4 08:07:01 PM UTC 2026
jetlag: started date as pid 2265842
Sun Jan  3 08:07:01 PM UTC 2027
```

## Reset the clock of a running program

This step uses two terminals, both in the repository root.

1. In the first terminal, start a loop that prints the date every second. `--listen` serves the Jetlag API for this program.

```
bin/jetlag run --offset 30d --listen 127.0.0.1:7420 -- sh -c 'while true; do date -u; sleep 1; done'
```

The loop prints dates 30 days ahead.

```
jetlag: started sh as pid 2265942
jetlag: listening on http://127.0.0.1:7420
Sun Jan  3 08:07:06 PM UTC 2027
Sun Jan  3 08:07:07 PM UTC 2027
```

2. In the second terminal, ask Jetlag for the state of the program. `child` is the program that `jetlag run` started and what it started.

```
bin/jetlag status --server http://127.0.0.1:7420 --target child
```

The first number after `tree:` is the pid of `sh`, so yours will differ. `+30d` is the Offset.

```
tree:2265942: 2 processes
  PID      COMM   MODE       OFFSET  WALL CLOCK
  2265942  sh     advancing  +30d    2027-01-03T20:07:09Z
  2265956  sleep  advancing  +30d    2027-01-03T20:07:09Z
```

3. Put the clock back to real time.

```
bin/jetlag reset --server http://127.0.0.1:7420 --target child
```

```
tree:2265942: 2 processes
  PID      COMM   MODE  OFFSET  WALL CLOCK
  2265942  sh     real  0s      2026-12-04T20:07:10Z
  2265972  sleep  real  0s      2026-12-04T20:07:10Z
```

4. Look at the first terminal. The same loop, which Jetlag did not restart, now prints today's date. Press Ctrl-C to stop it.

```
Sun Jan  3 08:07:09 PM UTC 2027
Fri Dec  4 08:07:10 PM UTC 2026
Fri Dec  4 08:07:11 PM UTC 2026
```

## Check what you built

Both paths are ignored by git.

```
bin/jetlag
third_party/epochd
```

## Next steps

Open the [docs](https://jetlag.slopkit.dev/docs/) for every command, the Target forms, the HTTP API and what a process Jetlag did not start needs.
