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.