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

1 Answer 1

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(); 
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.