0 like 0 dislike
40 views
How to zip all files named with test in centos via PHP
in Education & Reference by (620 points) | 40 views

1 Answer

0 like 0 dislike
echo $res = `find /var/www/html/Test -maxdepth 1 -name "test*"  -daystart -mtime 0 -ls`;

//0 means from today , so for example 1 means 1 day old

$main_array = (explode(PHP_EOL,$res));
//print_r($main_array);

$main_array = array_map(function($arr){ $a = explode("/", $arr, 2); return $a[1]; }, $main_array);
//print_r($main_array);
$main_array = array_map(function($arr){ $a = explode("/", $arr); $size = sizeof($a) - 1; return $a[$size]; }, $main_array);

$cmd = "tar -zcvf test-".date(Ymd).".tgz ";
$files = implode(" ", $main_array);

$rese = `$cmd.$files`;
//echo "==>".$cmd.$files;

by

Related questions

0 like 0 dislike
1 answer
1 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
1 like 0 dislike
1 answer
0 like 0 dislike
1 answer
1 like 0 dislike
1 answer
asked Jan 4, 2018 in Education & Reference by Sam (1.3k points) | 311 views
0 like 0 dislike
1 answer
asked May 29, 2019 in Education & Reference by Marc (2.4k points) | 66 views

Where your donation goes
Technology: We will utilize your donation for development, server maintenance and bandwidth management, etc for our site.

Employee and Projects: We have only 15 employees. They are involved in a wide sort of project works. Your valuable donation will definitely boost their work efficiency.

How can I earn points?
Awarded a Best Answer 10 points
Answer questions 10 points
Asking Question -20 points

1,202 questions
1,347 answers
553 comments
1,994 users