Detailed introduction to Linux timing Tasks Crontab_unix Linux

Source: Internet
Author: User
Tags php script

First, the preface

The crontab command is common in UNIX and unix-based operating systems, and is used to set periodically executed instructions. This command reads the instruction from the standard input device and stores it in a user-named file in the "crontab" file (/var/spool/cron/ for later reading and execution. The word derives from the Greek chronos (χρνο), which is intended to be time.

Typically, crontab stored instructions are run in the background by daemon-crond activation, checking every minute for scheduled jobs to be performed. This type of assignment is commonly referred to as cron jobs.

Ii. initiation of the Crond process

Service Crond Start

If not installed, please install first:

Yum install Vixie-cron

yum install Crontabs

Third, crontab common orders:

crontab -e edit crontab file, edit Crond process automatically read

 crontab -llist Details of user crontab files

crontab -r Delete crontab file

Four, crontab file format

The crontab file is made up of 6 parts

1, minute one hour in which minute [0-59]

2. Which hour of hour day [0-23]

3. Which day of the Day-of-month January [1-31]

4, month-of-year of the year of January [1-12]

5, Day-of-week One day of the week [0-6]

6, commands to execute the order

None of these options is empty, and you can use * to represent any time if the user does not need to make several of them.

You can specify multiple values per time field, separated by commas, 5-8 */5

3 * * 1-5 echo > Aa.txt

As indicated above, perform the scheduled task 3:15 every Monday to week 5.

Five, which users can use the crontab command

/etc/cron.allowIf this file exists, only users in this file can use the crontab command, and if the file does not exist, find/etc/cron.deny

/etc/cron.deny If this file exists, the crontab command is not available to users in this file

If 2 files do not exist, only root can use the crontab command

If all 2 files exist and are empty, all users can use the crontab command

Six, timing tasks combined with PHP

Timing PHP is easy, just replace the command with a PHP script, which means that the index.php is executed every 1 minutes.

*/1 * * * * php/usr/www/test/index.php

Vii. Summary

The above is about Linux time task crontab all the content, we have learned it? I hope this article will help you learn or use Linux, thank you for your support to the cloud-dwelling community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.