How to execute PHP program in Linux under Crontab timer

Source: Internet
Author: User
This article introduces the method of executing PHP program with crontab timing in Linux system. Please refer to the friends who are in need.

In Linux, the method of executing PHP with crontab Timing is implemented as follows:

1. Use Crontab-e to edit the contents of the Timed tasks:

Xx:xx:xx executing a hello.php file

2. php files must be in the header line of the file, plus the interpreter path (similar to bash or Perl)

#!/usr/local/bin/php

Note: PHP execution requires Apache support, and the execution of shell scripts requires Linux support, while Linux supports the ability to run a program on a timed basis. Then, execute directly in/etc/crontab, as in the following notation:

*/5 * * * * root/root/hello.php

The previous practice, first in the crontab to execute a shell program, and then let the shell program to run PHP program, this is actually quite inefficient, instead directly in the/etc/crontab directly with the PHP path, such as

*/5 * * * * root PHP hello.php

, and it can be executed correctly;

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