1. No Profile Picture
    Registered User
    Devshed Novice (500 - 999 posts)

    Join Date
    Dec 2005
    Rep Power

    Linux Zip from php script doesn't complete

    We are working on a new backup script and have ran into an issue. We run a php script to ssh into a remote server, zip a folder and download it. The problem we're having is the zip doesn't always complete with all folders. We can watch it zip the folders and its contents, and we can see the temp zip file in the target location, but then when the zip command is finished compressing the files, the temp files stays and the zip is not created. This problem seems sporadic. Some folders compress fine, some don't. Furthermore, if we manually try to zip the folders that give us issues, they will zip fine, this is only a problem when we run it from our script.
    Here is a part of our script.

    PHP Code:
    echo "---- .... ZIP Creation - ".$cleanHost." .... ----\r\n";
    "---- .... ".$homeDir." .... ----\r\n";
    "zip -r ".$cleanHost.".zip /".$homeDir."\r\n";

    $output $ssh->exec('zip -r '.$cleanHost.'.zip /'.$homeDir);
    Please and thanks.
  2. #2
  3. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Bonita Springs, FL
    Rep Power
    If your script is being run through a webserver and the zipping process takes a long time to complete then it may be getting killed due to a timeout. For example, if you are using Apache with mod_fcgid to run your PHP scripts then either of FcgidIdleTimeout or FcgidIOTimeout could be killing it. If using mod_fastcgi, then the -idle-timeout option may also be a culprit.

    A problem with the SSH connection could also cause the zip process to terminate early. Check for timeouts there and network stability.

    Check PHP's timeout settings.
    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud

IMN logo majestic logo threadwatch logo seochat tools logo