1. automatically delete temporary files at every day
First, check the crontab task list:
Crontab-l
Then create:
Crontab-e
Add a row:
00 03 *** rm-rf/www/cmstest/my120/public/scripts/jpgraph /*
Save and exit.
Restart the service:/etc/rc. d/init. d/crond restart
2. Automatic database backup at every day
The system crontab is used to regularly execute Backup files and save the backup results by date to achieve the purpose of backup.
1. Create the path to save the backup file/mysqldata
# Mkdir/mysqldata
2. Create the/usr/sbin/bakmysql file.
Find the path of the database file:
Usually:/var/lib/mysql, Or,/usr/local/mysql/var
Search Method:
1./usr/local/mysql/bin/mysql-u root-p enter the database
2. Input: show databases;
3. You can view all the databases and
4. find/-name db (name of the database you want to search)
After: # vi/usr/sbin/bakmysql
Input
Copy codeThe Code is as follows: rq = 'date + % Y % m % d'
Tar zcvf/mysqldata/mysql1_rq.tar.gz/var/lib/mysql
3. Modify file attributes to make them executable.
# Chmod + x/usr/sbin/bakmysql
Create a task:
First, check the crontab task list:
Crontab-l
Then create:
Crontab-e
Add a row
00 04 ***/usr/sbin/bakmysql
Indicates that the backup is performed at 24 o'clock every day.
4. Restart crond.
#/Etc/rc. d/init. d/crond restart
After that, you can see a similar file in/mysqldata every day: mysql20040619.tar.gz.