Shell-Packaging, compression, and decompression instructions summary

Source: Internet
Author: User
Packaged

Tar

Cpio

Compression

Zip

bz2

Example:

① Batch compression script: tar-gzip-dir-rm.sh

Implementation features: Compressed directory under all folders for the same name packaging compressed files (tar.gz), compression after successful deletion;

Script code:

  1. #!/bin/bash
  2. For i in ' ls |grep-v tar.gz |grep ';d o
  3. Nice-n tar-cf $i. tar.gz-z $i && rm-rf $i
  4. # Nice worth reducing to prevent because the compression causes the server to be too jammed,
  5. Done

Script execution:

Nohup Bash tar-gzip-dir-rm.sh &

# The execution of the command is associated with terminal detachment (the execution environment is Xshell), preventing execution failures due to network or other unexpected conditions.

② in the log storage directory, each day will produce a log folder, require writing a cron file, to achieve automatic compression of log files, and delete the log folder

Implementation features: Automatically compress the log folder generated by the same name, compressed files, compressed successfully deleted the original folder;

Code:

  1. #cron –e
  2. # * * * * * * */bin/bash/path/to/tar-gzip-dir-rm.sh &>/dev/null

Shell-Packaging, compression, and decompression instructions summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.