Shell Script implementation: 5 per week using the tar command to back up all log files under/var/log

Source: Internet
Author: User
Simple little script, big God Detour

Implementation steps:
1 Writing scripts
2 Doing recurring planning tasks

1 scripting
[Email protected] ~]# vim tar.sh
Script content:
#!/bin/bash
#编写备份脚本, the file name contains a date label after the backup, preventing subsequent backups from overwriting the previous backup data
#注意将date命令使用反引号扩起来, the inverted quotation marks indicate the implementation of the reference command
TAR-ZCF log- date +%F . Tar.gz/var/log
[Email protected] ~]# chmod +x/root/tar.sh

2 Doing recurring planning tasks
[Email protected] ~]# CRONTAB-E
0 3 5/root/tar.sh

The task is complete.

Shell Script implementation: 5 per week using the tar command to back up all log files under/var/log

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.