Creating zipped nightlies using cron

software development


I want to programmatically create ZIP files of an actively developed piece of software I’m writing, and I’d like to do so on a nightly basis.

In other words, I want to ZIP /home/username/ (the sw/ directory and everything in it), and I’d like the ZIP file saved to /home/username/

I know how to ZIP via Shell; while in the (using the above example) to/ directory, I ran “zip sw sw” and shell reported that the ZIP was created successfully. I just have NO idea where it saved it too… It’s not in the path/, to/, sw/ or even in home/username/…

What I’d like is for the ZIP to be created each night at midnight.

I cannot for the life of me figure out what to put in the command box of the DH panel’s cron interface. I’ve wasted a few hours on this, so I hope one of you is able to help me out. Thanks!

  1. For cron jobs specify full paths, including to programs or shell scripts, eg:$ whereis zip zip: /usr/bin/zip /usr/share/man/man1/zip.1.gzprogram = /usr/bin/zip
    zip file = /home/username/
    source directory = /home/username/

  2. Second, I don’t know what zip program you invoked, but the version on my machine is as follows: says this:[code]$ zip -v
    This is Zip 2.31 (March 8th 2005), by Info-ZIP.
    Currently maintained by Onno van der Linden. Please send bug reports to
    the authors using; see README for details.

Latest sources and executables are at, as of
above date; see for other sites.

Compiled with gcc 3.3.5 (Debian 1:3.3.5-8) for Unix (Linux ELF) on Mar 23 2005.[/code]3. If you want the file paths in the zip to start with ‘sw/’ then change to the parent directory first. Won’t need to specify full path to sw directory in the call to zip as a result.

  1. Need to add -r flag to recourse directories and -q to suppress output if necessary

  2. So far you should have these commands to make the zip and then verify:$ [b]cd /home/username/[/b] $ [b]/usr/bin/zip -r /home/username/ sw[/b] adding: sw/ (stored 0%) ... $ [b]/usr/bin/stat /home/username/[/b] File: `/home/username/' Size: 41534 Blocks: 88 IO Block: 32768 regular file Device: 10h/16d Inode: 281900410 Links: 1 Access: (0664/-rw-rw-r--) Uid: (4096/ username) Gid: (16384/ pg8192) Access: 2009-08-25 12:21:17.694192000 -0700 Modify: 2009-08-25 12:21:17.711192000 -0700 Change: 2009-08-25 12:21:17.712193000 -0700 $6. So if you want to run all 3 commands for the cronjob, you need to separate them using a semi-colon on one line:
    cd /home/username/; /usr/bin/zip -r /home/username/ sw; /usr/bin/stat /home/username/

Customer since 2000 :cool:


Genius, dude. Thanks!