Linux task scheduling exercises

Case 1: Every 1 minute, append the current date information to the / tmp / mydate file

  1. First write a file /home/mytask1.sh, write the following command
    date >> / tmp / mydate in the file
  2. Give mytask1.sh an executable permission of
    chmod 744 /home/mytask1.sh
  3. crontab -e
  4. */1 * * * * /home/mytask1.sh

Case 2: Every 1 minute, append the current date and calendar to the / home / mycal file

  1. First write a file /home/mytask2.sh
date >> /tmp/mycal cal >> /tmp/mycal
  1. 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 .

  1. First write a file /home/mytask3.sh
/usr/local/mysql/bin/mysqldump -u root -proot testdb > /tmp/mydb.bak
  1. Give mytask3.sh an executable permission
chmod 744 /home/mytask3.sh
crontab -e
0 2 * * *	/home/mytask3.sh

crond related instructions:

  1. conrtab -r: Terminate task scheduling.
  2. crontab –l: List those tasks currently scheduled
  3. service crond restart [Restart task scheduling]
Published 48 original articles · Likes0 · Visits 282

Guess you like

Origin blog.csdn.net/qq_44971387/article/details/105342585