Advertisement
Typhoon

PHP RSYNC Copy Cron Script

May 19th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. # Created by @Pytlicek and Milan Huska
  2. <?php
  3. # Date Function for Logging
  4. $today = date("Y-m-d H:i:s");
  5.  
  6. # Open or Create Log File
  7. $myfile = fopen("/home/hosting_user/www_root/log.html", "a") or die("Unable to open file!");
  8.  
  9. # Create array of file paths
  10. $file_paths = array('/home/hosting_user/somefolder/1/1_xml.zip','/home/hosting_user/somefolder/2/1_xml.zip');
  11.  
  12. # Copy file from source to destination file path / paths (from array)
  13. foreach ($file_paths as &$value) {
  14.     # Source File Path
  15.     $source_file = '/home/hosting_user/source_folder/1_xml.zip';
  16.     # Copy File from source to destination : as $value in current loop
  17.     copy($source_file, $value);
  18.     # Optional : Print status if it is successfully created
  19.     echo "OK File : " . $value . "<br />";
  20.     # Define text to Log and write it to LogFile
  21.     $txt = $today . " OK File : " . $value . "\n";
  22.     fwrite($myfile, $txt);
  23.  
  24. }
  25. # Close File after processing
  26. fclose($myfile);
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement