# Scheduled restarts on a FiveM server

> Set up scheduled FiveM restarts in txAdmin: choosing times, the automatic warnings, the events to hook for saving data, skipping a restart and crash recovery.

Source: https://fam-tools.com/guides/fivem-scheduled-restarts · FAM Tools · published 2026-09-11 · updated 2026-09-11 · about 8 min

**Short answer.** In txAdmin’s settings, add restart times (24-hour `HH:MM`). txAdmin broadcasts `txAdmin:events:scheduledRestart` 30, 15, 10, 5, 4, 3, 2 and 1 minutes before, with `secondsRemaining`, and `txAdmin:events:serverShuttingDown` right before stopping. Save player data in those handlers. Admins can skip the next restart from the dashboard; crashes are restarted automatically.

## Key points

- Schedule 2–4 restarts a day at quiet times.
- Warnings: 30, 15, 10, 5, 4, 3, 2, 1 minutes.
- Save data on `scheduledRestart` (e.g. at 60 s) and `serverShuttingDown`.
- Skipping a restart broadcasts `scheduledRestartSkipped`.
- Restarts hide leaks; profiling fixes them.

Most roleplay servers restart two to four times a day. It clears leaked entities and memory, applies updated resources and gives the database a quiet moment. txAdmin does the scheduling, warns players and tells your scripts to save before the server goes down.

## Setting the schedule

1. Open txAdmin → Settings → Restarter.
2. Add restart times in 24-hour format, for example `06:00`, `14:00`, `22:00`.
3. Save. The next restart time appears on the dashboard.

> **Pick quiet times** — Look at your player graph and place restarts in the dips — and never in the middle of your busiest evening hour.

## Saving data before the restart

*server.lua*

```lua
AddEventHandler('txAdmin:events:scheduledRestart', function(data)
    if data.secondsRemaining == 60 then
        -- one minute left: save everything
        SaveAllPlayers()
    end
end)

AddEventHandler('txAdmin:events:serverShuttingDown', function(data)
    -- data.delay = ms before txAdmin kills the process
    SaveAllPlayers()
end)
```

`SaveAllPlayers` stands for your framework’s save function. `serverShuttingDown` fires for every stop or restart — scheduled, by an admin, or by the system — so it is the safest single place to save.

## Skipping and temporary restarts

From the dashboard an admin can skip the next scheduled restart (for an event running late) or schedule a one-off restart. Skips broadcast `txAdmin:events:scheduledRestartSkipped`, so a countdown UI can hide itself.

## Crash recovery

txAdmin monitors the server and restarts it when it crashes or stops responding. If it restarts often, read the console and crash logs instead of relying on it — see [txAdmin setup](https://fam-tools.com/guides/txadmin-setup-guide).

## How often is right?

Every 6–8 hours suits most servers. If performance falls apart between restarts, a resource is leaking entities or memory: profile it rather than restarting more often — see [server performance](https://fam-tools.com/guides/fivem-server-performance) and [entity limits](https://fam-tools.com/guides/fivem-entity-limits-cleanup).

## Questions

### How do I schedule restarts in txAdmin?

Settings → Restarter, add times in 24-hour `HH:MM` format and save.

### When does txAdmin warn players about a restart?

30, 15, 10, 5, 4, 3, 2 and 1 minutes before a scheduled restart.

### How do I save player data before a restart?

Handle `txAdmin:events:scheduledRestart` (for example at 60 seconds remaining) and `txAdmin:events:serverShuttingDown`.

### How often should a FiveM server restart?

Commonly every 6–8 hours, at quiet times.

## Related

- https://fam-tools.com/guides/txadmin-setup-guide
- https://fam-tools.com/guides/fivem-server-backups
- https://fam-tools.com/guides/fivem-server-performance
- https://fam-tools.com/guides/fivem-entity-limits-cleanup
