1 logging into a Linux server using putty
2 Enter the following command. View existing Scheduled Tasks
Crontab-l
3 Enter the following command to enter the scheduled task file
Crontab-e
4 Keyboard Select I key for input, ESC key exit: Wq Save and exit
Example: Write a file that executes every five minutes
*/5 * * * * * /usr/local/php/bin/php /home/wwwroot/default/push.php
5 Viewing results Crontab-l
Content Description:
/usr/local/php/bin/php : Installation path for PHP
/home/wwwroot/default/push.php script files that need to be executed
* * * * * command
Time-sharing Weekly command
The 1th column represents minutes 1~59 per minute with * or */1
The 2nd column represents the hour 1~23 (0 means 0 points)
The 3rd column represents the date 1~31
The 4th column represents the month 1~12
5th Column Identification Number Week 0~6 (0 = Sunday)
timed task: crontab
usage rights: All users
Usage: The
crontab file [-u user]-replaces the current crontab with the specified files.
Crontab-[-u user]-replaces the current crontab. with standard input;
crontab-1[user]-lists the user's current crontab.
Crontab-e[user -Edit the user's current crontab.
crontab-d[user]-Delete the user's current crontab.
Crontab-c dir-Specifies the crontab directory. The format of the
Crontab file: 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 Sunday).
Cmd to run the program, the program is sent to SH execution, the shell only user,home,shell these three environment variables
Description
Crontab is used to allow a user to execute a program at a fixed time or at a fixed interval, in other words, a user-like schedule. -u user refers to setting the specified
User's time table, which presupposes that you must have permission (for example, root) to specify another's time schedule. If you do not use the-u user, it means to set the
Set your own schedule.
Parameters:
CRONTAB-E: Do a text editor to set the time table, the default text editor is VI, if you want to use another text editor, please set the VISUAL environment variables first
To specify the use of that text editor (for example, Setenv VISUAL Joe)
Crontab-r: Delete the current schedule table
Crontab-l: List the current schedule
crontab file [-u user]-replaces the current crontab with the specified files.
The format of the schedule table is as follows:
F1 F2 F3 f4 f5 program
Where F1 is expressed in minutes, F2 represents hours, F3 represents the day of the month, F4 represents the month, and F5 represents the day of the one week. program says
The program of the line.
When F1 is * indicates that every minute the program,f2 is executed, the program is executed every hour, and the remainder of the analogy
When the F1 is a-B, it is executed from the time of the minute to the minute of the hour, and the F2 is a-B indicating that it is executed from the first and the other, and the other analogy
When F1 is */n, it is performed once every n minutes, and F2 is */n for every n-hour interval, with the remainder of the other analogy
When F1 is a, B, C,... A, B, C,... Minutes to execute, F2 for a, B, C,... The time indicated that the first, B, c ... Hours to execute, and the rest of the analogy
The user can also store all the settings in the file file, using the crontab file to set the time schedule.
Some examples of crontab files:
- * * * * * */usr/local/etc/rc.d/lighttpd restart // The above example shows that 21:30 restarts Apache per night.
$ 4 1,ten, * */usr/local/etc/rc.d/lighttpd restart // The above example represents 4 per month for 1, 10, 22nd : 45 Restart Apache.
Ten 1 6,0 /usr/local/etc/rc.d/lighttpd Restart // The above example shows that 1:10 restarts Apache per Saturday and Sunday.
0.-* * * * */usr/local/etc/rc.d/lighttpd restart // The above example shows that the Apache is restarted every 30 minutes from 18:00 to 23:00 every day.
0 at 6 /usr/local/etc/rc.d/lighttpd Restart // The above example indicates that the Apache is restarted every Saturday.
0 */1 * * */usr/local/etc/rc.d/lighttpd restart //
0 7/1 * * */usr/local/etc/rc.d/lighttpd restart //
0 One 4 * mon-wed/usr/local/etc/rc.d/lighttpd restart //
0 4 1 Jan */usr/local/etc/rc.d/lighttpd restart //
Linux Crontab timed Task Usage instance