cloud images

Use cron to extract and compress (zip & unzip) on Cloud Sites

Scripting extraction and compression of files

General Process:

In Cloud Sites, the general process for extracting and compressing files through a cron job consists of the following steps:

Creating the script File

Uploading the aforementioned file to the site through FTP.

Scheduling the cron job through the Cloud Sites Control Panel's Features tab.

IMPORTANT NOTE: Please make sure that you set up the cron job "command type" to be Perl to properly execute the shell script (.sh file). Cron jobs that run over 900 seconds (15 minutes) are automatically terminated.

Creating the Script File

To create the script file, simply open up a text editor on your local machine and copy/paste the sample code (provided in the examples below) for the operation you wish to accomplish:

I. Compressing

Suggested Filename: compress.sh

NOTE: For these examples make sure to replace "/SOURCE/DIRECTORY/" and "/DESTINATION DIRECTORY" with the appropriate Web directories (like "/mnt/stor1-wc1-dfw1/123456/www.example.com/web/content/archives/").

Zip compression

To compress a directory to zip format add these lines to the script:

#!/bin/sh
zip -9pr /DESTINATION/DIRECTORY/file.zip /SOURCE/DIRECTORY/

Where "file.zip" is the name that you assign to the zip file.

The final script should look similar to this:

Note: If you're only compressing a single file the script would be similar, but would not require the "r" in the options.