PHPLinux scheduled task settings

Source: Internet
Author: User
PHPLinux scheduled task settings 1. crontab cannot be saved

Run select-editor to select the second nano... Then run crontab-e to write and exit the program according to the following prompt ^ O and ^ X. Or select 3 and use vim to edit it.

Configuration steps:

1. the PHP interpreter must be compiled and installed in Linux. after installation, copy the $ {PHP}/bin/php file under the installation directory

/Usr/bin/, and use chmod + x./php to add executable permissions to it. OK,

Then enter php-q *. php in the linux command line.

Execute a php program to verify whether the interpreter works properly

2. publish the php file: publish the compiled php program to the apache Publishing Directory, for example,/var/www/html.

Add permission: chmod + x/var/www/html/*. php

3. create a scheduled task:

(1) start the linux Scheduled service: service crond start

(2) view the current scheduled task: crontab-l

(3) add a new scheduled task: crontab-e

Edit in the opened file:

*/2 *****/usr/bin/php-f/var/www/html/*. php

Indicates that the/var/www/html/*. php file is executed every 2 minutes.

* 23 ***/usr/bin/php-f/var/www/222.com/www/ipphone/timingcall.php

Executed 60 times from

01 23 ***/usr/bin/php-f/var/www/222.com/www/ipphone/timingcall.php

Execute at PM. execute once in total

(Note:-f is very important and cannot be changed to-q)

4. verify whether the crontab file exists

If crontab-e fails, modify the command in the user file in/var/spool/cron/crontabs.

To verify whether your crontab file exists, use the ls-l command in the/var/spool/cron/crontabs directory.


* Ls indicates that the ls command is executed every 5th minutes of an hour.

30 5 *** ls specifies to execute the ls command at every day

30 7 8 ** ls: specify to execute the ls command at on the 8 th of every month.

30 5 8 6 * ls specifies to execute the ls command at on January 1, June 8 each year.

30 6 ** 0 ls specify to execute the ls command at every Sunday [Note: 0 indicates Sunday, 1 indicates Monday,

Similarly, sun represents Sunday, mon represents Monday, and so on.]

30, 20 ** ls: execute the ls command at on the 10th and 20th of every month [note: "," is used to connect multiple discontinuous periods]

25 8-11 *** ls execute the ls command 25th minutes at every day [note: "-" is used to connect consecutive periods]

*/15 * ls: execute the ls command every 15 minutes [that is, execute the ls command every hour for 0th 15 30 45 60 minutes]

30 6 */10 ** ls: execute the ls command at every 10 days. ]

Run all executable files in the/etc/cron. daily directory as root at every day.

50 7 * root run-parts/etc/cron. daily [Note: run-parts parameter indicates that all executable files in the following directory are executed. ]

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.