Introduction to the Linux Foundation of Experimental Building (new Edition)-BACKUP log __linux

Source: Internet
Author: User
Topic

Xiaoming is a server administrator, he needs to back up the forum data every day (here we use log substitution), back up the day's log and delete the previous log. And the file name is the year-month-day format after the backup. Alternatives.log is below/var/log/. Target Shiyanlou users add Scheduled Tasks 3 o'clock in the morning every day scheduled backup Alternatives.log to/home/shiyanlou/tmp/directory naming format is year-month-day, such as today is April 1, 2017, Then the file name is 2017-04-01 prompt date crontab CP (Backup) with a command written in the crontab can be, do not write a script to pay attention to crontab plan user
->CRONTAB-E represents adding a task schedule for the current user
->sudo CRONTAB-E represents adding a task plan solution for root users: 1. Add tmp directory

$ mkdir tmp
2. Start Rsyslog
$ sudo service rsyslog start
3. Start Crontab
$ sudo cron-f &
4. Edit Crontab file
$ crontab-e

/USR/BIN/SELECT-EDITOR:32:/usr/bin/select-editor:gettext:not found
1-3 []: 1 (or 3)
Press A to start editing
On the last line of the file, enter:

0 3 * * * cp/var/log/alternatives.log/home/shiyanlou/tmp/$ (date+ \%y\%m\%d)  

CTRL + C, exit edit mode;
shift+ ': ', Input: Wq, exit.

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.