Linux task scheduler (8)

crond task scheduling:

  It refers to the system to perform a specific command or application at a time.

  Category: 1, the system work, and some important work must be performed again and again, such as virus scanning; 2, individual users work, individual users may wish to perform certain procedures, such as mysql database backup

The basic syntax:

  crontab [options]

  [-E] cron job edit crontab

  [-L] Query task crontab

  [-R] to delete the current user's crontab all tasks

Case: / etc / crontab

  

  * / 1 * * * * ls -l / etc >> /tmp/to.txt: do not add content to to.txt in minutes

  Parameter details Description:

    * For any time, such as the first representative of a * hours a once per minute

    Representative discontinuous time, such as "0 8,12,16 * * *" represents the day 8:00, 12:00, 16:00 execute a command

    - represents the continuous time range, such as "* 1-6 * 05" represents Monday to Saturday 5:00 Run

    * / N representative of how often executed once. As represented in the example described above is performed once every minute command

Task set by the script file:

  1, writing shell scripts, such as vim /home/mytask.sh

    date >> /tmp/mydate

  2, an executable permission to mytask.sh

    chmod 744 /home/mytask.sh

  3、crontab -e

    */1 * * * * /home/mytask.sh

Restart task scheduling:

  service crond start

Guess you like

Origin www.cnblogs.com/az4215/p/11410309.html