Using a timer: in the logs directory, a file is generated every two minutes

1. Use the timer: In the logs directory, a file is generated every two minutes
(the file format is: 201711151323.log, 201711151323.log, 2017111513xx.log ...
Idea: The timer calls the shell script regularly, and the script creates the file according to the time,
And append the content of the file beicai.log to the log file.

#vi filetime.sh
#!/bin/bash
cd /home/hadoop/hadoop-2.6.1/logs
d=`date +%Y%m%d%H%M`
touch $d.log
cd /home/hadoop
cat beicai.log >> /home/hadoop/hadoop-2.6.1/logs/$d.log


#crontab -e
*/2 * * * * /home/hadoop/filetime.sh

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325367074&siteId=291194637