1. Run in the background, waking up at 5AM to process your config, then going back to sleep until tomorrow.
2. Run immediately, process the config, then exit [the container, if you are running in docker]
These two modes are mutually exclusive, and the first is the default behavior.
While it is possible to have `python kometa.py` running in an open window constantly, this is not the recommended approach as it relies on an always-open command window that can be obtrusive to the user.
Instead, it is recommended to set an automated scheduling service so that Kometa can run in the background when scheduled to without any visible impact to the user (other than the Plex libraries and playlists updating).
This page discusses how to set up this "When should Kometa run" level of schedule, and it leverages both the "modes" of running discussed above.
**You can also put schedule information in your config to control things like "process the Movie library only on Tuesdays" or the like. That level of scheduling is independent of when Kometa runs, and is discussed [here](../../config/schedule.md)**
When running Kometa within docker, the session will resume after a system reboot (assuming Docker is set to start at system startup, which is the default) and Kometa will run in the background at all times.
There's a [Docker Walkthrough](../install/docker.md) with more detailed instructions on setting up Kometa within docker. The simplest command to facilitate a docker run is:
<TIMEZONE> is replaced with your local timezone, or the timezone your device is in that is running Kometa. For a list of available timezones, please see [Timezones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). You want to replace <TIMEZONE> with the TZ Database Name.
This will run Kometa in the background persistently until it is stopped by the user. While the docker container will be persistently running, Kometa will not begin the run until the scheduled time.
Further customizations of the docker run command can be used to specify set times to run Kometa, further information on this and other Run Commands can be found [here](../environmental.md#time-to-run)
Windows Task Scheduler is advised for those who followed the Windows instructions in the [Local Walkthrough Guides](../install/local.md) and/or do not want to run Kometa within docker.
These guides assume the user has followed the Windows instructions in the [Local Walkthrough Guides](../install/local.md) which includes setting up the [virtual environment](../install/local.md#setting-up-a-virtual-environment). Please also ensure to edit any commands to be reflective of the live environment (such as usernames, installation directories).
This method will start Kometa at system startup and will keep Kometa running in the background indefinitely. The user can then define set days and times for the Configuration File to be processed, and Kometa will handle processing as and when required.
If you don't specify a time, the script will run at 5AM each day. You can change this with the [time-to-run](../environmental.md#time-to-run) runtime flag.
* This will navigate to the Kometa directory, then run Kometa. At the scheduled time [as defined within Kometa], Kometa will process the Configuration File and will then wait until the next scheduled time.
7. Click "Browse", Navigate to the Kometa directory and choose `waiter.cmd`, which was created in Step 1, then select "Open". NOTE: Your path may vary from the illustration here; navigate to the file you created and saved in Step 1.
8. Copy the directory everything up to but not including `waiter.cmd` from the "Program/Script" field, and paste it into the "Start in" field. This is `C:\User\IEUser\Kometa-1.15.1` in the example below, then select "next". NOTE: Your path may vary from the illustration or example.
Kometa will now launch at system startup, but will wait until the user-specified scheduled time before executing, and will then wait in the background for the next scheduled run.
This method will start Kometa at the desired time, immediately begin running the Configuration File and will then kill the process once it has completed.
* This will navigate to the Kometa directory, then launch Kometa using the `-r`/`--run` flag which triggers an immediate run. Once complete, Kometa will exit.
9. Copy the directory everything up to but not including `runner.cmd` from the "Program/Script" field, and paste it into the "Start in" field. This is `C:\User\IEUser\Kometa-1.15.1` in the example below, then select "next".
The cron utility is used for running scripts and commands at regular intervals, and at specific times and dates. It’s built into most Operating Systems (namely Linux and Mac), and provides a very useful way to schedule tasks on your server. It also works for running Docker commands on a schedule.
3. Paste in the crontab line you got from `crontab-generator`, or type in one of your own. Depending on the editor being used, you may need to put it into insert mode first. There's a good chance it's `vi`, in which case you need to press `i` to put it into insert mode, after which you will see `-- INSERT -- ` in the lower left.
4. Save and close the file. How you do that depends on which editor is being used. There's a good chance it's `vi`, in which case `ESC : w RETURN` will save and `ESC : q RETURN` will exit.