There is a code for working with images, the purpose of which is, and compression of images. Problems arise in the lack of resources. Scripting is incomplete with error 504.

function backupimage($dir){ foreach (scandir($dir) as $key) { $imageiofile = "/home/bitrix/ext_www/" . "host.svarbi.ru/upload/iblock/".$key."/*.*"; foreach (glob($imageiofile) as $filename) { // echo basename($filename)."\n"; $newfile = "/home/bitrix/ext_www/host.svarbi.ru/ttt/aaa/" .$key."/".basename($filename); if (!copy($filename, $newfile)) { echo "не удалось скопировать $file...\n"; } } } } backupimage($dir); 

It is necessary to break it all into pieces and do it. Which algorithm is better for this?

  • Unfortunately 504 = ( - Basil Jimmy
  • As with the Dos attack - Basil Jimmy
  • one
    Such tasks need to be done not through the web server, but in the console via ssh, for example. You most likely do not have enough timeout. - ilyaplot
  • one
    What kind of staff? Script on the crown and all. - ilyaplot
  • one
    no one bothers to start the execution of php script from the command line php /path/to/my/script.php . Alternatively, enter an interpreter ( #!/path/to/php ) at the beginning of the file, and set the rights to execute ( +x ) the php file, and simply write it in cron. so there is no need for a bash or a python - teran

1 answer 1

This script will never work correctly. First, filter the resulting scandir values ​​(exclude '.' '..' from the results). Probably after that everything will work.