I'm searching for a option to remove all unused images I'm searching for a option to remove all unused images every minute.

The images I use are for Craft Commerce.
Best way to handle this is probably with a console command provided by a module.

The console command would need to fetch all asset IDs that don’t have any corresponding rows in the relations database table.

use Craft;
use craft\db\Query;
use craft\db\Table;
use craft\elements\Asset;
use yii\console\ExitCode;
use craft\helpers\Console;

public function actionPurgeUnusedAssets(): int
{
    // Find any asset IDs that aren't related to anything
    $assetIds = (new Query())
        -&gt;select(['a.id'])
        -&gt;from(['a' =&gt; Table::ASSETS])
        -&gt;leftJoin(Table::RELATIONS . ' r', '[[r.targetId]] = [[a.id]]')
        -&gt;where(['r.id' =&gt; null])
        -&gt;column();

    if (empty($assetIds)) {
        $this-&gt;stdout('No unrelated assets to delete.' . PHP_EOL);
        return ExitCode::OK;
    }

    // Now fetch and delete them
    $assets = Asset::find()
        -&gt;id($assetIds)
        -&gt;all();

    $this-&gt;stdout('Found ' . count($assets) . ' unrelated assets.' . PHP_EOL);

    foreach ($assets as $asset) {
        $this-&gt;stdout(" - Deleting asset {$asset-&gt;filename} ... ");
        Craft::$app-&gt;elements-&gt;deleteElement($asset);
        $this-&gt;stdout('done' . PHP_EOL, Console::FG_GREEN);
    }

    $this-&gt;stdout('Finished deleting unrelated assets.' . PHP_EOL);
    return ExitCode::OK;
}


Then, you can set up a cron job on your server that hits this command every 24 hours.

0 0 * * * /path/to/project/craft your-module/purge-unused-assets