Debian timed php Setup method

Source: Internet
Author: User
Keywords Execution Php debian

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Recently followed the eldest brother to learn how to do the site, they bought a VPS, is going to build a site in the work of the usual after the application of the study to see the effect. The so-called practice of truth. The first problem that comes up is. PHP scripts are required to do something regularly. In fact, there are two ways to plan your PHP tasks:

1. Let the server execute the PHP script regularly. 2. Judge the time when the user accesses the script, and then perform the tasks before the page is exported. (The latter is not really about execution, just before the user finishes the thing, and then the user looks like it's timed to execute)

The second method, although simple, requires users to visit PHP each time to determine whether the task is executed according to time. Every time it comes to unnecessary consumption. Since I bought VPS then, let the server do these things well. My VPS is using the Debian system. Baidu just a moment ago set the method of planning tasks, the test of their own really effective, set the method as follows:

1. After landing the VPS to run the command: Vi/etc/crontab

2. Here you can add commands for scheduled tasks.

3. Command explanation: The Scheduled Task command is divided into three parts. 1. Time 2. User 3. Tasks performed

You can find a way to set the time from the following command:

3:00 Daily:

0 3 * * * Root command

Every Sunday 8:30:

8 * * 7 root command

1 weeks 5 0 o'clock per week:

0 0 * * 1,5 root command

May 12 14 o'clock every year:

0 5 * Root command

Every 15 minutes from 18 o'clock in the evening to 23 points:

*/15 18-23 * * * Root command

Instance:

Visit a PHP script once per minute:

* */1 * * * Root wget-o/var/log/cron.txt http://www.4j4j.cn/

Check whether PHP automatically runs every minute, you can see the Var/log/cron.txt file, whether it is the site PHP returned content on it! Before think very complex very difficult things, in fact, as long as serious Baidu, do more experiments, basic can learn. Hope also just start to learn how to do Web site users can also stick to learning.

Related Article

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.