The following instance is used in the Centos6.5 64-bit operating system
One, the regular copy file
A. Create the tomcatback.sh file in the/usr/local/wfjb_web_back directory
File contents:
#将tomcat中的应用wfjb_web copied to the/usr/local/wfjb_web_back/tomcat_back/directory and followed by the date as the file name
cp-af/usr/local/apache-tomcat-7.0.73/webapps/wfjb_web/usr/local/wfjb_web_back/tomcat_back/$ (date-d "Today" + "%Y% m%d_%h%m%s ")/
B. Give executable permissions to the tomcatback.sh file
Chmod-r 777 tomcatback.sh
C. Create a timed task
Add a scheduled task at the end of the/etc/crontab file
0 1 * * * root/usr/local/wfjb_web_back/tomcatback.sh #每天凌晨一点执行tomcatBack. sh This file
D. Finally restart the Crontab service for the newly configured scheduled tasks to take effect
Service Crond Restart
second, scheduled backup MySQL database
A. Create the backdb.sh file in the/usr/local/wfjb_web_back directory
File contents:
#将数据库testDB full backup to the/usr/local/wfjb_web_back/wfjbdb_back/directory and follow the date as the file name
d=$ (Date +%y%m%d)
Mysqldump-u root-ptestdb123456 TestDB >/usr/local/wfjb_web_back/wfjbdb_back/${d}.sql
B. Give executable permissions to the backdb.sh file
Chmod-r 777 backdb.sh
C. Create a timed task
Add a scheduled task at the end of the/etc/crontab file
0 2 * * * root/usr/local/wfjb_web_back/backdb.sh #每天凌晨两点执行backDB. sh This file
D. Finally restart the Crontab service for the newly configured scheduled tasks to take effect
Service Crond Restart
Three, crontab scheduled Tasks
Execute */5 every five minutes * * * *
Executes 0 per hour * * * *
Executes 0 0 * * * per day
Weekly Execution 0 0 * 0
Monthly execution 0 0 1 * *
Annual Execution 0 0 1 1 *
Using the shell to automate script files under Linux