1

I want to run a command to remove all files under the folder 'allfiles/'

root@admin:/home/admin/allfiles# find . -name '*' | xargs rm

and it clears all files under allfiles

I want to run the same command using Laravel Schedule, I am using in this way

protected function schedule(Schedule $schedule)
{

    $schedule->exec('find . -name '*' | xargs rm /home/admin/millionfiles/')
             ->everyMinute(); 
}

But it does not work

Anonymous Girl
  • 582
  • 8
  • 22

1 Answers1

2

You missed ' before the directory beginning

Also try adding double quotes instead of single

protected function schedule(Schedule $schedule)  {
    $schedule-> exec('find . -name "*" | xargs rm ' . '/home/admin/millionfiles/')
             ->everyMinute(); 
}