Use in monitoring projects * * * *:
sudo crontab-u wangyan-e
I
5,25,45 * * * * wget http://xxx.xxx.com/xxx/xx
Esc
: Wq
View: sudo crontab-u wangyan-l
Delete: sudo crontab-u wangyan-r
Basic KNOWLEDGE * * * *:
1. Execute script in crontab using URL:
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://
2, CodeIgniter scheduled task Cron Schedule 0.1
Http://blog.chinaunix.net/uid-26559452-id-3093545.html
3, Baidu Encyclopedia:Now let's start with cron: the pronunciation "' Kr?n"In a Linux system, the scheduled tasks are generally assumed by cron, and we can set cron to start automatically when booting." After Cron starts, it reads all of its configuration files (global profile/etc/crontab, and each user's scheduled task profile), and Cron invokes the work task on time, based on the command and execution time. Cron is a timed execution tool under Linux that can run a job without human intervention. Since Cron is a built-in service for Linux, it does not automatically get up, you can start and shut down this service in the following ways:/sbin/service crond start//start service/sbin/service Crond stop//Shut down service/sbin/ Service Crond restart//restart Services/sbin/service Crond Reload//Reload configuration You can also start the service automatically when the system starts: at the end of the script, add:/ Sbin/service Crond Start now cron This service is already in the process, we can use this service, The Cron service provides the following interfaces for your use: 1. Use the crontab command to edit the cron service to provide the crontab command to set the Cron service, here are some parameters and instructions for this command: crontab-u//Set a user's Cron service, The general root user needs this parameter when executing this command crontab-l//list details of a user cron service Crontab-r//delete a user's Cron service CRONTAB-E// Edit a user's Cron service for example, root to view his cron settings: Crontab-u root-l Again, for example, Root wants to delete Fred's cron settings: crontab-u fred-r When editing the cron service, there are some formatting and conventions for the edited content. Input: Crontab-u root-e Enter VI edit mode, the content of the edit must conform to the following format: */1 * * * * ls >>/tmp/ls.txtcrontab file format: M H d M D cmd. M: Minutes (0-59). H: Hours (0-23). D: Day (1-31). M: Month (1-12). D: Day of the Week (0~6,0 is Sunday). The first part of this format is the setting of the time, the latter part is the command to execute, if you want to execute too many commands, you can write these commands to a scriptInside, and then call this script directly here, remember to write the full path of the command when calling. Time setting we have a certain agreement, the front five * number represents five numbers, the value range and the meaning of the numbers are as follows: minutes (0-59) hours (0-23) Date (1-31) month (1-12) week (0-6)//0 for Sunday In addition to the numbers there are a few special symbols that are "*", "/" and "-", ",", * represents all the values within the range of numbers, "/" stands for each meaning, "*/5" represents every 5 units, "-" represents a number from one digit to a number, "," separates several discrete numbers. Here are a few examples to illustrate the problem: 6 a.m. 0 6 * * * echo "Good morning." >>/tmp/test.txt//Note simply Echo, no output from the screen, Because cron emails any output to Root's mailbox. Every two hours 0 */2 * * * echo "has a break now." >>/tmp/test.txt 11 o'clock to 8 a.m. every two hours in the morning eight points 0 23-7/2,8 * * * echo "have a good D Ream:) ">>/tmp/test.txt 4th per month and Monday to Sunday three morning 11 0 4 * 1-3 command line1 month 1st morning 4 Point 0 4 1 1 * command line every time you edit a user's CR On set, Cron automatically generate a file with the same name as this user under/var/spool/cron, this user's cron information is recorded in this file, this file can not be edited directly, can only be edited with CRONTAB-E. After Cron starts, read the file once every one of the clocks, and check to see if you want to execute the command inside. Therefore, the Cron service does not need to be restarted after this file has been modified. 2. Edit the/etc/crontab file configuration Croncron service every minute not only to read all the files in/var/spool/cron, but also to read the/etc/crontab, so we configure this file can also use the Cron service to do something. The crontab configuration is for a user, while the edit/etc/crontab is a task for the system. The file format for this file is: Shell=/bin/bashpath=/sbin:/bin:/usr/sbin:/usr/binmailto=root//If an error occurs, or if there is data output, the data is sent to this account as a messagehome=///user Run path, here is the root directory # RUN-PARTS01 * * * * root run-parts/etc/cron.hourly//hourly Execute script within/etc/cron.hourly 4 * * * Root R un-parts/etc/cron.daily//Daily Execute script within/etc/cron.daily 4 * * 0 root run-parts/etc/cron.weekly//weekly execution/etc/ Script within cron.weekly 4 1 * * Root run-parts/etc/cron.monthly//monthly to execute scripts within/etc/cron.monthly
Linux crontab timed task calls the CI framework PHP code