gzipping to a different directory

Problem: You want to compress files, but the file system is not large enough in which to compress the files.

Solution: Compress the files to an alternate (larger) file system using gzip's --to-stdout (-c) and shell redirection, remove the original file, and move the compressed file to the original location.

Example:

# pwd
/var/adm

# ls -l wtmpx.OLD
-rw-r--r--   1 root     other    591931980 Aug  6 09:30 wtmpx.OLD

# df -k /var

Filesystem            kbytes    used   avail capacity  Mounted on
/dev/md/dsk/d3       1016122  869649   85506    92%    /var

# df -k /files0
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/md/dsk/d5       31387621 2365849 28707896     8%    /files0

# gzip --best --to-stdout wtmpx.OLD > /files0/wtmpx.OLD.gz
# rm wtmpx.OLD
# mv /files0/wtmpx.OLD.gz .

Back to brandonhutchinson.com.
Last modified: 2007/08/06