Linux Task Scheduling (8)


Crond task scheduling:

It means that the system executes a specific command or program at a certain time.

Classification: 1. System work, some important work must be performed repeatedly, such as virus scanning; 2. Individual user work, individual user may wish to execute some programs, such as MySQL database backup.

Basic grammar:

Crontab [option]

[-e] Editing Crontab Timing Tasks

[-l] Query Crontab Tasks

[-r] Delete all crontab tasks for the current user

Case: / etc/crontab


*/ 1 * * * * ls – L / etc > / TMP / to. txt: No minutes to add content to. TXT

Details of parameters:

* Represents that at any time, for example, the first * represents the total execution of an hour every minute.

Represents a discontinuous time, such as “0 8,12,16* *” means that an order is executed at 8:0, 12:0 and 16:0 every day.

– Represents a continuous time range, such as “0.5* * 1-6” implements orders from Monday to Saturday at 5:0 a.m.

*/ n stands for how often it is executed. As in the example above, the command is executed every minute on behalf of the representative.

Setting tasks through file scripts:

1. Write shell scripts, such as vim/home/

    date >> /tmp/mydate

2. Give an executable privilege

    chmod 744 /home/

  3、crontab -e

    */1 * * * * /home/

Restart task scheduling:

  service crond start