Linux uses crontab to implement timed tasks for PHP

Source: Internet
Author: User

Http://www.phpddt.com/php/linux-crontab.html

Crontab
Yum Installcrontabs //installation instructions:/sbin/service Crond Start//Start the service/sbin/service Crond Stop//Close Service/sbin/service Crond Restart//Restart Service/sbin/service Crond Reload//Reload Configuration View crontab Service Status:crond status manual start crontab Service: Servicescrond start   To see if the Crontab service is set to boot, execute the command:ntsysv //Not successfully added to boot automatically: chkconfig–level *Crond on

Crontab Task Command:

crontab [-u < user name >][profile] or crontab [-u < user name >][-ELR]-e Edit the user's timer settings. -L lists the user's timer settings. -R removes the user's timer settings. -u< User name > Specifies the user name to set the timer.

Contab format

Minute Hour Day Month DayOFWeek Command

Example:

1. Create a PHP file to execute

#!/usr/local/php/bin/php-<? PHP     Echo  Date ('y-m-d h:i:s'). " from http://www.phpddt.com \ n " ;? >

2. Settings can be performed

chmod +x test.php

3, Crontab-e writing

* * * * * */root/test.php >> Test.log

This step can be written on the PHP path, you do not need 1, 2 steps

/usr/bin/php -f/root/test.php >> test.log

4. View Results

Vim/root/test.log

Http://www.jb51.net/article/29136.htm

Use URL to execute script in crontab:

Use curl to access the URL to execute PHP scripts every 5 minutes. Curl defaults to show output in standard output. With the "curl-o" option, you can also dump the output of the script to a temporary file.


*/5 * * * */usr/bin/curl-o temp.txt http://

Use the wget access URL to execute PHP scripts every 10 minutes. The-q option indicates quiet mode. "-O Temp.txt" indicates that the output is sent to a temporary file.

* * * * * * */usr/bin/wget -q-o temp.txt http://

Linux uses crontab to implement timed tasks for PHP

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.