Case 1: Every 1 minute, append the current date information to the / tmp / mydate file
- First write a file /home/mytask1.sh, write the following command
date >> / tmp / mydate in the file- Give mytask1.sh an executable permission of
chmod 744 /home/mytask1.sh- crontab -e
- */1 * * * * /home/mytask1.sh
Case 2: Every 1 minute, append the current date and calendar to the / home / mycal file
- First write a file /home/mytask2.sh
date >> /tmp/mycal cal >> /tmp/mycal
- Give mytask1.sh an executable permission
chmod 744 /home/mytask2.sh
crontab -e
*/1 * * * * /home/mytask2.sh
Backup the mysql database testdb to the file
mydb.bak at 2:00 AM every day .
- First write a file /home/mytask3.sh
/usr/local/mysql/bin/mysqldump -u root -proot testdb > /tmp/mydb.bak
- Give mytask3.sh an executable permission
chmod 744 /home/mytask3.sh
crontab -e
0 2 * * * /home/mytask3.sh
crond related instructions:
- conrtab -r: Terminate task scheduling.
- crontab –l: List those tasks currently scheduled
- service crond restart [Restart task scheduling]