Long-running tasks

There are a few tasks Shlink needs to perform which are too heavy or time-consuming to be executed when a user visits a short URL.

In order to redirect end users as fast as possible to the final URLs, these tasks have been left for you to configure when and how often should they be executed.

Locate visits

Shlink provides the command visit:locate which will process all the IP addresses from visits in order to locate them.

You can of course run it manually from time to time, but it is a good idea to schedule its execution.

When serving Shlink with swoole, locating visits is automatically done just after redirecting end users. However, it might be a good idea to have previous scheduling in place, as a backup in case some of those asynchronous processes fail.

Generate page previews

Shlink is capable of generating the preview of a page behind a short code by appending the /preview suffix to any short URL. For example, https://doma.in/abc123/preview.

If you access any of those URLs, the image will be generated and cached, but the first time, the request will take a little bit more time.

In order to pre-generate those previews, you can use the command short-url:process-previews, which will generate all missing previews so that any later request resolves faster.

Scheduling the execution of that command might be a good idea if you are planning to make use of these previews.


One way to schedule any of the previous tasks is by making use of Unix cron jobs:

For example, this cron will locate visits every hour. The -q flag is available on any Shlink command and will discard any output generated from it.

0 * * * * /path/to/shlink/bin/cli visit:locate -q