Created
May 8, 2014 07:05
-
-
Save msurguy/62158555be9f4a98378f to your computer and use it in GitHub Desktop.
Clean temporary folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Console\Command; | |
use Symfony\Component\Console\Input\InputOption; | |
use Symfony\Component\Console\Input\InputArgument; | |
class CleanDirs extends Command { | |
protected $name = 'cleandirs'; | |
protected $description = 'Cleans directories.'; | |
public function __construct() | |
{ | |
parent::__construct(); | |
} | |
public function fire() | |
{ | |
$now = time(); | |
foreach(File::directories('public/uploads/temp') as $dir ){ | |
$dirtime = filemtime($dir); | |
if( $now-$dirtime > 3600){ | |
File::deleteDirectory($dir); | |
$this->info('Directory '.$dir.' was deleted'); | |
} | |
} | |
} | |
protected function getArguments() | |
{ | |
return array( | |
array('example', InputArgument::OPTIONAL, 'An example argument.'), | |
); | |
} | |
protected function getOptions() | |
{ | |
return array( | |
array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment