Automatic deletion of temporary files 23:00 daily
First look at the crontab task list:
Crontab-l
And then NEW:
Crontab-e
Add a line:
* * * rm-rf/www/cmstest/my120/public/scripts/jpgraph/*
Save exit.
Restart Service:/etc/rc.d/init.d/crond restart
Second, daily 24:00 automatically back up the database
Use the system crontab to execute the backup file regularly, save the backup result by date, and achieve the purpose of backup.
1, create the path to save the backup file/mysqldata
#mkdir/mysqldata
2. Create/usr/sbin/bakmysql files
To find the path to a database library file:
Are generally:/var/lib/mysql, or,/usr/local/mysql/var
Find Method:
1,/usr/local/mysql/bin/mysql-u root-p into the database
2, input: show databases;
3, this is to be able to view all the databases, and then
4, Find/-name db (You want to look up the name of the database)
After: #vi/usr/sbin/bakmysql
Input
Copy Code code as follows:
rq= ' Date +%y%m%d '
Tar Zcvf/mysqldata/mysql$rq.tar.gz/var/lib/mysql
3, modify the file properties to make it executable
# chmod +x/usr/sbin/bakmysql
New task:
First look at the crontab task list:
Crontab-l
And then NEW:
Crontab-e
Add a row
* * * */usr/sbin/bakmysql
Indicates a backup is performed 24 o'clock daily
4. Reboot Crond
#/etc/rc.d/init.d/crond Restart
Every day after that, you can see a similar file in/mysqldata: mysql20040619.tar.gz.