syncDBToRedis();exit; // $service->insertMappings();exit; // $service->syncImageFiles(); // exit; // $baseDir = "/Users/shixuesen/Documents/sync/image"; $baseDir = "/Users/shixuesen/Documents/otherSync"; $dirs = ["tumblr__0048"]; $files = []; foreach ($dirs as $dir) { $currentFiles = scandir($baseDir . DIRECTORY_SEPARATOR . $dir); foreach ($currentFiles as $file) { if ($file == "." || $file == ".." || $file == ".DS_Store") { continue; } $files[] = $baseDir . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $file; } // $files = array_merge($files, $currentFiles); } $md5Set = []; // $newDir = "/Users/shixuesen/Downloads/y/Nagisa魔物喵202003fantia会员合集/魔物喵__001"; // mkdir($newDir); $i = 0; foreach ($files as $file) { if ($file == "." || $file == ".." || $file == ".DS_Store") { continue; } $hash = md5_file($file); if (array_key_exists($hash, $md5Set)) { echo "file is same $file, and {$md5Set[$hash]} \n"; // rename($dir . DIRECTORY_SEPARATOR . $file, $newDir . DIRECTORY_SEPARATOR . $file); // exit; $i++; } else { $md5Set[$hash] = $file; } } echo "all same file count is $i"; exit; // $pid = pcntl_fork(); $childs = array(); $cmds = array( array('/Users/shixuesen/Downloads/temp/dir1/1.txt', '/Users/shixuesen/Downloads/temp/dir2/1.txt'), array('/Users/shixuesen/Downloads/temp/dir1/1.txt', '/Users/shixuesen/Downloads/temp/dir3/1.txt'), array('/Users/shixuesen/Downloads/temp/dir1/1.txt', '/Users/shixuesen/Downloads/temp/dir4/1.txt') ); echo 'begin'; echo date("Y-m-d H:i:s"); foreach ($cmds as $cmd) { $pid = pcntl_fork(); if ($pid == -1) {// process creation failed die('fork child process failure!'); } else if ($pid) {// parent process logic $childs[] = $pid; pcntl_wait($status, WNOHANG); } else {// sub-process processing logic pcntl_exec('/bin/cp', $cmd); } } while (count($childs) > 0) { foreach ($childs as $key => $pid) { $res = pcntl_waitpid($pid, $status, WNOHANG); //1 for error, greater than 0 representative process has been withdrawn, returns to the pid of the sub-process, and 0 representatives have not been able to take the exit sub-process when it is not blocked if ($res == -1 || $res > 0) unset($childs[$key]); } sleep(1); } echo "start sleep"; sleep(100); echo date("Y-m-d H:i:s"); echo 'done'; exit; echo time() . "\n"; $pid = pcntl_fork(); if ($pid == -1) { die('could not fork'); } else if ($pid) { // we are the parent pcntl_wait($status); //Protect against Zombie children } else { // we are the child pcntl_exec("/bin/cp", ["/Users/shixuesen/Downloads/temp/dir1/1.txt", "/Users/shixuesen/Downloads/temp/dir2/1.txt"]); } pcntl_exec("/bin/cp", ["/Users/shixuesen/Downloads/temp/dir1/1.txt", "/Users/shixuesen/Downloads/temp/dir3/1.txt"]); pcntl_exec("/bin/cp", ["/Users/shixuesen/Downloads/temp/dir1/1.txt", "/Users/shixuesen/Downloads/temp/dir4/1.txt"]); echo time(); exit; $service = new GooglePhotoSyncService(); // $service->syncDBToRedis();exit; // $service->insertMappings();exit; $service->syncImageFiles(); exit; // $service = new FileService(); // $service->queryFileTime("/Users/shixuesen/Documents/sync/image/instagram/mobe_carrie0223/mobe__0020/82339160_561812341080795_8865402232426240219_n.jpg");exit; // echo $service->processDirAndFindLastFileMTime("/Users/shixuesen/Documents/sync/image/weibo/");exit; // $service = new LiveStreamService(); // $service->moveFilesAndRenameFiles("/Users/shixuesen/Downloads/rsyncFiles/a", "/Users/shixuesen/Downloads/rsyncFiles/b"); // exit; // $a = str_replace("/", "", "aaaaa/bbbb"); // echo $a;exit; // $file = "/Volumes/Crucial X6/Image/weibo/image/一只小短短OwO--7f605a17gy1gxpb0pg31vj22eo37k1kz.jpg"; $file = "/Users/shixuesen/Documents/sync/image/instagram/Likes/eeelyeee_277962893_719835709026094_2370282265319075961_n.jpg"; // $file = "/Users/shixuesen/OneDrive/Pictures/instagram/Likes_new/eeelyeee_277962893_719835709026094_2370282265319075961_n.jpg"; $file = "/Users/shixuesen/Documents/sync/image/instagram/boram__jj/277958530_1581189285586989_5049761303029075957_n.jpg"; // $file = "/Users/shixuesen/OneDrive/Pictures/instagram/boram__jj/277958530_1581189285586989_5049761303029075957_n.jpg"; $mtime = date("Y-m-d H:i:s", filemtime($file)); $atime = date("Y-m-d H:i:s", fileatime($file)); $ctime = date("Y-m-d H:i:s", filectime($file)); // $stat = stat($file); echo "file mtime is $mtime, atime is $atime, ctime is $ctime"; // dump($stat); } }