Linux system backup logs

Source: Internet
Author: User
Tags rsyslog

Topic:

Backup Log

Xiaoming is a server administrator who needs to back up the forum data every day (here we replace with the log), back up the day's logs and delete the previous logs. and 年-月-日 the format of the file name after the backup. Alternatives.log is below/var/log/.

Goal
    1. To add a scheduled task to a Shiyanlou user
    2. Regular backup of Alternatives.log to/home/shiyanlou/tmp/directory at 3 o'clock in the morning every day
    3. The naming format is 年-月-日 , for example, today is April 1, 2017, then the file name is2017-04-01
Tips
    • Date
    • Crontab
    • CP (Backup)
    • Write it in crontab with a command, without writing a script.

Note: If fail does not have any prompt information, please refresh the page. Note Crontab's program users

crontab -e 表示为当前用户添加计划任务sudo crontab -e 表示为root用户添加计划任务


Answer:
1. Start the log server
sudo service rsyslog start
2. Start the crontab service
sudo cron-f &
3. Enter the crontab file
crontab-e
4. Edit Auto-start content
0 3 * * * cp/var/log/alternatives.log/home/shiyanlou/tmp/' date+%y-%m-%d '


If cron-f & startup failure occurs

Rm-rf/var/run/crond.pid

Restart Service Rsyslog Start




Linux system backup logs

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.