Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

patgilmour's avatar

Telescope data pruning outside of php artisan

php artisan help telescope:prune explains that, for example, the following will delete all telescope entries older than 12 hours: php artisan telescope:prune --hours=12

In the online Laravel manual, there is something similar, only set with a variable: $schedule->command('telescope:prune')->daily(); or, similar to above with hours, $schedule->command('telescope:prune --hours=48')->daily();

My questions:

  • When I run php artisan telescope:prune --hours=12 is this a one-time event? Or does this mean that, for this Laravel project, all entries older than 12 hours will be pruned going forwards?
  • I'm assuming the above is a one-time event and that I need to include $schedule->command('telescope:prune --hours=12'); somewhere in my Laravel code is I want pruning to happen when the app is run. If this is the case, where should I include the code?
  • In the code with the $schedule variable, I have excluded ->daily() because I am running the "prune" at intervals of less than daily. Is this correct?

Thanks for any insights!

0 likes
3 replies
audunru's avatar
audunru
Best Answer
Level 4

When I run php artisan telescope:prune --hours=12 is this a one-time event? Or does this mean that, for this Laravel project, all entries older than 12 hours will be pruned going forwards?

It's a one time event.

I'm assuming the above is a one-time event and that I need to include $schedule->command('telescope:prune --hours=12'); somewhere in my Laravel code is I want pruning to happen when the app is run. If this is the case, where should I include the code?

It should go in app/Console/Kernel.php. Take a look at https://laravel.com/docs/5.8/scheduling#defining-schedules

In the code with the $schedule variable, I have excluded ->daily() because I am running the "prune" at intervals of less than daily. Is this correct?

I can see what you mean, but if you omit daily() you need to tell how often you want the command to run.

As you can read in https://laravel.com/docs/5.8/scheduling#introduction the scheduler should be setup to run every minute. This just means that Laravel will run every minute, checking which tasks in Kernel.php should be run. So you could add $schedule->command('telescope:prune --hours=12')->daily() or perhaps $schedule->command('telescope:prune --hours=12')->hourly() if you want to get rid of old data quicker.

3 likes
patgilmour's avatar

Thank you, Audunru! Very useful answers.

I've been trying to go through the entire documentation but hadn't looked into scheduling yet. Seems that the missing pieceso will give it a look over on your recommendation.

1 like
AntLusher's avatar

They should do a link off to the related resource

Please or to participate in this conversation.