Introduction crontab-Operates the daemon of each user and the schedule of the execution. Some parameters Description crontab file [-u user] - replaces the current crontab with the specified file. Crontab - [- u user] - replaces the current crontab. crontab-1 [user] with standard input, lists the current crontab. crontab-e [user] - edit the user's current crontab. crontab-d [user] - Delete the current crontab. Crontab-c dir- specifies the catalog of crontabs. CRONTAB file format: M H D m D cmd. M: Minute (0-59). H: Hours (0-23). D: Day (1-31). M: Month (1-12). D: The sky within a week (0 ~ 6, 0 is Sunday). CMD To run the program, the program is sent to the SH execution, this shell has only three environment variables of User, HOME, Shell. Below is an example of an example file: #MIN HOR DAY MONTH Dayofweek Command # 6:10 per day 10 6 * * * Date # Every two hours 0 * / 2 * * * Date # 11 points to 8 points in the morning Two hours, 8:00 23-7 / 2, 8 * * * Date # Every month 4 and each worship of the worship of the worship 3 in the morning 11:00 11 4 * MON-WED DATE # 1 Month Day 4 0 4 1 Jan * Date Sample $ crontab -l Lists users' current crontab. # Hour day month dayofweek Command 10 6 * * * Date 0 * / 2 * * * Date 0 23-7 / 2 , 8 * * * Date
-------------------------------------------------- ----
CRONTAB Note 1
Edit crontab: # crontab -e automatically calls VI Press INSER to enter the editing status About every minute (hour) usage should be: * / 5 * * * fsck / home, you can write: 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 * * * * FSCK / Home Continuous Time Method No. 1 to 10: 0 0 1-10 * * FSCK / Home Combination Get up together on Sunday, 8:00 pm, every two hours: 0 8-18 / 2 * * 7 fsck / home Press ESC to exit editing status, press: WQ Save and leave CROND # / etc / init. D / crond restart
-------------------------------------------------- ----
Supplement 2
/usr/lib/cron/cron.allow said anyone can use the crontab command. If it is an empty file that indicates that there is no user to schedule a job. If this file does not exist, there is another file /usr/lib/cron/cron.deny, only the crontab command can only be used if the user is not included in this file. If it is an empty file that indicates that any user can schedule a job. Cron.allow is preferred when the two files exist, if there is no existence, only superusers can schedule jobs. -------------------------------------- How to delete a directory in RH Linux What about all files?
Find $ dir_you_want -ctime -3 -a -type f -exec / bin / rm {} /; find $ dir_you_want -ctime 3 -Type F | xargs rm -rf ------------- -------------------------------------------------- Perform backup and empty the current log file, clear_countlog.shzcatlinux, #! / Bin / bashlogfile = / var / count.logdate = `DATE % Y% M% D`IF [-f $ logfile] THEN CP $ logfile $ Logfile- $ DATE FIND / VAR /-CTIME 3 -NAME Count / * -exec rm {} /; echo "> $ logfilefi implements the above script every day in crontab!
10 3 * * * root /home/clear_countlog.sh
Supplement 2
/usr/lib/cron/cron.allow said anyone can use the crontab command. If it is an empty file that indicates that there is no user to schedule a job. If this file does not exist, there is another file /usr/lib/cron/cron.deny, only the crontab command can only be used if the user is not included in this file. If it is an empty file that indicates that any user can schedule a job. Cron.allow is preferred when the two files exist, if there is no existence, only superusers can schedule jobs. -------------------------------------- How to delete a directory in RH Linux What about all files?
Find $ dir_you_want -ctime -3 -a -type f -exec / bin / rm {} /; find $ dir_you_want -ctime 3 -Type F | xargs rm -rf ------------- -------------------------------------------------- Perform backup and empty the current log file, clear_countlog.shzcatlinux, #! / Bin / bashlogfile = / var / count.logdate = `DATE % Y% M% D`IF [-f $ logfile] THEN CP $ logfile $ Logfile- $ DATE FIND / VAR / -DIME 3 - Name Count / * -exec rm {} /; echo "> $ logfilefi
Implement the above script once a day in crontab!
10 3 * * * root /home/clear_countlog.sh
-------------------------------------------------- ----
Supplement 2
/usr/lib/cron/cron.allow said anyone can use the crontab command. If it is an empty file that indicates that there is no user to schedule a job. If this file does not exist, there is another file /usr/lib/cron/cron.deny, only the crontab command can only be used if the user is not included in this file. If it is an empty file that indicates that any user can schedule a job. Cron.allow is preferred when the two files exist, if there is no existence, only superusers can schedule jobs. -------------------------------------- How to delete a directory in RH Linux What about all files?
Find $ dir_you_want -ctime -3 -a -type f -exec / bin / rm {} /; find $ dir_you_want -ctime 3 -Type F | xargs rm -rf ------------- -------------------------------------------------- Perform backup and empty the current log file, clear_countlog.shzcatlinux, #! / Bin / bashlogfile = / var / count.logdate = `DATE % Y% M% D`IF [-f $ logfile] THEN CP $ logfile $ Logfile- $ DATE FIND / VAR /-CTIME 3 -NAME Count / * -exec rm {} /; echo "> $ logfilefi implements the above script every day in crontab!
10 3 * * * root /home/clear_countlog.sh
Supplement 2
/usr/lib/cron/cron.allow said anyone can use the crontab command. If it is an empty file that indicates that there is no user to schedule a job. If this file does not exist, there is another file /usr/lib/cron/cron.deny, only the crontab command can only be used if the user is not included in this file. If it is an empty file that indicates that any user can schedule a job. Cron.allow is preferred when the two files exist, if there is no existence, only superusers can schedule jobs. -------------------------------------- How to delete a directory in RH Linux What about all files?
Find $ dir_you_want -ctime -3 -a -type f -exec / bin / rm {} /; find $ dir_you_want -ctime 3 -Type F | xargs rm -rf ------------- -------------------------------------------------- Perform backup and empty the current log file, clear_countlog.shzcatlinux, #! / Bin / bashlogfile = / var / count.logdate = `DATE % Y% M% D`IF [-f $ logfile] THEN CP $ logfile $ Logfile- $ DATE FIND / VAR / -DIME 3 - Name Count / * -exec rm {} /; echo "> $ logfilefi
Implement the above script once a day in crontab!
10 3 * * * root /home/clear_countlog.sh
CRONTAB Note 1
Edit crontab: # crontab -e automatically calls VI Press INSER to enter the editing status About every minute (hour) usage should be: * / 5 * * * fsck / home, you can write: 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 * * * * FSCK / Home Continuous Time Method No. 1 to 10: 0 0 1-10 * * FSCK / Home Combination Get up together on Sunday, 8:00 pm, every two hours: 0 8-18 / 2 * * 7 fsck / home Press ESC to exit editing status, press: WQ Save and leave CROND # / etc / init. D / crond restart
-------------------------------------------------- ---- Supplement 2
/usr/lib/cron/cron.allow said anyone can use the crontab command. If it is an empty file that indicates that there is no user to schedule a job. If this file does not exist, there is another file /usr/lib/cron/cron.deny, only the crontab command can only be used if the user is not included in this file. If it is an empty file that indicates that any user can schedule a job. Cron.allow is preferred when the two files exist, if there is no existence, only superusers can schedule jobs. -------------------------------------- How to delete a directory in RH Linux What about all files?
Find $ dir_you_want -ctime -3 -a -type f -exec / bin / rm {} /; find $ dir_you_want -ctime 3 -Type F | xargs rm -rf ------------- -------------------------------------------------- Perform backup and empty the current log file, clear_countlog.shzcatlinux, #! / Bin / bashlogfile = / var / count.logdate = `DATE % Y% M% D`IF [-f $ logfile] THEN CP $ logfile $ Logfile- $ DATE FIND / VAR / -DIME 3 - Name Count / * -exec rm {} /; echo "> $ logfilefi
Implement the above script once a day in crontab!
10 3 * * * root /home/clear_countlog.sh
Supplement 2
/usr/lib/cron/cron.allow said anyone can use the crontab command. If it is an empty file that indicates that there is no user to schedule a job. If this file does not exist, there is another file /usr/lib/cron/cron.deny, only the crontab command can only be used if the user is not included in this file. If it is an empty file that indicates that any user can schedule a job. Cron.allow is preferred when the two files exist, if there is no existence, only superusers can schedule jobs. -------------------------------------- How to delete a directory in RH Linux What about all files?
Find $ dir_you_want -ctime -3 -a -type f -exec / bin / rm {} /; find $ dir_you_want -ctime 3 -Type F | xargs rm -rf ------------- -------------------------------------------------- Perform backup and empty the current log file, clear_countlog.shzcatlinux, #! / Bin / bashlogfile = / var / count.logdate = `DATE % Y% M% D`IF [-f $ logfile] THEN CP $ logfile $ Logfile- $ DATE FIND / VAR / -DIME 3 - Name Count / * -exec rm {} /; echo "> $ logfilefi
Implement the above script once a day in crontab!
10 3 * * * root /home/clear_countlog.sh
-------------------------------------------------- ---- Supplement 2
/usr/lib/cron/cron.allow said anyone can use the crontab command. If it is an empty file that indicates that there is no user to schedule a job. If this file does not exist, there is another file /usr/lib/cron/cron.deny, only the crontab command can only be used if the user is not included in this file. If it is an empty file that indicates that any user can schedule a job. Cron.allow is preferred when the two files exist, if there is no existence, only superusers can schedule jobs. -------------------------------------- How to delete a directory in RH Linux What about all files?
Find $ dir_you_want -ctime -3 -a -type f -exec / bin / rm {} /; find $ dir_you_want -ctime 3 -Type F | xargs rm -rf ------------- -------------------------------------------------- Perform backup and empty the current log file, clear_countlog.shzcatlinux, #! / Bin / bashlogfile = / var / count.logdate = `DATE % Y% M% D`IF [-f $ logfile] THEN CP $ logfile $ Logfile- $ DATE FIND / VAR / -DIME 3 - Name Count / * -exec rm {} /; echo "> $ logfilefi
Implement the above script once a day in crontab!
10 3 * * * root /home/clear_countlog.sh
Supplement 2
/usr/lib/cron/cron.allow said anyone can use the crontab command. If it is an empty file that indicates that there is no user to schedule a job. If this file does not exist, there is another file /usr/lib/cron/cron.deny, only the crontab command can only be used if the user is not included in this file. If it is an empty file that indicates that any user can schedule a job. Cron.allow is preferred when the two files exist, if there is no existence, only superusers can schedule jobs. -------------------------------------- How to delete a directory in RH Linux What about all files?
Find $ dir_you_want -ctime -3 -a -type f -exec / bin / rm {} /; find $ dir_you_want -ctime 3 -Type F | xargs rm -rf ------------- -------------------------------------------------- Perform backup and empty the current log file, clear_countlog.shzcatlinux, #! / Bin / bashlogfile = / var / count.logdate = `DATE % Y% M% D`IF [-f $ logfile] THEN CP $ logfile $ Logfile- $ DATE FIND / VAR / -DIME 3 - Name Count / * -exec rm {} /; echo "> $ logfilefi
Implement the above script once a day in crontab!
10 3 * * * root /home/clear_countlog.sh