Allow running crons individually as separate commands #7651

Closed
opened 2025-11-02 07:32:29 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @clarfonthey on GitHub (Aug 2, 2021).

Basically, it would be very nice to be able to have a gitea cron (job) command that would manually execute each of the cron jobs without having to have them managed by the gitea process itself.

That way, they could be run by a separate cron process, or systemd. Then, it would even be possible to ensure that cron jobs are still run while potentially delaying the actual web instance of gitea with socket activation. This might be ideal for smaller setups, e.g. on a small home server, to avoid having to start everything at once on boot.

There are some commands that duplicate the various tasks that are run by crons, but there's not really any easily trackable set of commands for this. I might be wrong.

Originally created by @clarfonthey on GitHub (Aug 2, 2021). Basically, it would be very nice to be able to have a `gitea cron (job)` command that would manually execute each of the cron jobs without having to have them managed by the gitea process itself. That way, they could be run by a separate cron process, or systemd. Then, it would even be possible to ensure that cron jobs are still run while potentially delaying the actual web instance of gitea with socket activation. This might be ideal for smaller setups, e.g. on a small home server, to avoid having to start everything at once on boot. There are some commands that duplicate the various tasks that are run by crons, but there's not really any easily trackable set of commands for this. I might be wrong.
Author
Owner

@zeripath commented on GitHub (Aug 3, 2021):

All of the cron tasks require gitea to be running.

Cron tasks are available on the /api/v1/admin/cron endpoints and are hooked in to tea and @jolheiser 's other autogenerated cli.

There arguably needs to be some other logging and status reporting endpoints but you can start these tasks from the API already.

@zeripath commented on GitHub (Aug 3, 2021): All of the cron tasks require gitea to be running. Cron tasks are available on the `/api/v1/admin/cron` endpoints and are hooked in to `tea` and @jolheiser 's other autogenerated cli. There arguably needs to be some other logging and status reporting endpoints but you can start these tasks from the API already.
Author
Owner

@techknowlogick commented on GitHub (Aug 3, 2021):

e.g. on a small home server, to avoid having to start everything at once on boot.

This can already be done, refer to the RUN_AT_START config option.

@techknowlogick commented on GitHub (Aug 3, 2021): > e.g. on a small home server, to avoid having to start everything at once on boot. This can already be done, refer to the `RUN_AT_START` config option.
Author
Owner

@clarfonthey commented on GitHub (Aug 3, 2021):

I stated that poorly; I know that you can avoid starting the jobs on process start, but I meant explicitly being able to defer them to starting on boot, not process start. So, for example, you could restart gitea without having them run and without changing the config.

Why do all the crons require running gitea? It seems like many could be done without it.

@clarfonthey commented on GitHub (Aug 3, 2021): I stated that poorly; I know that you can avoid starting the jobs on process start, but I meant explicitly being able to defer them to starting on boot, not process start. So, for example, you could restart gitea without having them run and without changing the config. Why do all the crons require running gitea? It seems like many could be done without it.
Author
Owner

@techknowlogick commented on GitHub (Aug 4, 2021):

Why do all the crons require running gitea? It seems like many could be done without it.

Cron tasks include repo health checks, triggering mirror updates, disk & DB cleanups, and more. It is recommended that they aren't disabled. You can see an exhaustive list of cron tasks in your admin dashboard.

@techknowlogick commented on GitHub (Aug 4, 2021): > Why do all the crons require running gitea? It seems like many could be done without it. Cron tasks include repo health checks, triggering mirror updates, disk & DB cleanups, and more. It is recommended that they aren't disabled. You can see an exhaustive list of cron tasks in your admin dashboard.
Author
Owner

@clarfonthey commented on GitHub (Aug 4, 2021):

I get that, what I'm wondering is why those can't be delegated to separate commands and explicitly need a running web instance.

@clarfonthey commented on GitHub (Aug 4, 2021): I get that, what I'm wondering is why those can't be delegated to separate commands and explicitly need a running web instance.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7651