How do I automatically execute PHP code when I arrive at 00:00 every day?

Source: Internet
Author: User
Rt


Reply to discussion (solution)

Set up scheduled tasks on the server

Use the Department of Crontab, the test
http://blog.csdn.net/fdipzone/article/details/7263361

How do I automatically execute PHP code when I arrive at 00:00 every day?
Using Scheduled Tasks

Scheduled Tasks ....

XX * * * */usr/bin/php-f/home/wwwroot/default/test/test.php

Make a bat file that uses the schtasks system command to execute the PHP file code you want to execute regularly, click the bat file to execute it, but you can also add tasks to your computer's system tasks.

You can refer to Ecshop's scheduled tasks

Window can then add tasks to the system task
Crontab can be used under Linux

Create a job, execute a stored procedure

Ignore_user_abort (); PHP scripts can continue to execute even if the client disconnects (such as turning off the browser).
Set_time_limit (0); Execution time is unlimited, php default execution time is 30 seconds, you can allow the program to execute indefinitely
$time _year=date (' Y ', Time ());
if ($time _year%4==0 && ($time _year%100!=0 | | $time _year%400==0))
{
$days = 366;
}
Else
{
$days = 365;
}
$interval = $days *24*60*60; Run once every other year
do{

Here you can enter the code you want to execute

Sleep ($interval);

}while (TRUE);

Crontab ... Why do you let PHP do this thankless?

  • 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.