Crontab usage
Syntax: crontab [-u username] |-l |-r |-e |-v
-U: the user who specifies the crontab job
-L: list the current crontab job
-E: use $ EDITOR to edit crontab job
-V: lists the status of the current crontab job. Some shells may not support-v
Crontab file format:
Each row corresponds to a cron job
Each line is divided into six parts. Each part is separated by a space. The same part is separated by a comma.
Minute hour day_of_month month weekday command
* Used in the first five domains indicates all time points.
Minute: 0-59
Hour: 0-23,0 represents zero point
Day_of_month: 1-31
Month: 1-12
Weekday: 0-6, 0 indicates Sunday, and 1-6 indicates Monday to Saturday.
Command: the script or command to be executed.
$ Cat test_cron.sh
#! /Bin/sh
Export the system time to the file time.txt
Echo 'date'> time.txt
# View the current cronjob. The system prompts that the user's cronjob of habao is useless.
$ Crontab-l
No crontab for habao
# Add cronjob
$ Crontab-e
# No execution every minute
# Displaying the current system time # You can conveniently view the usage of scheduled jobs in the crontab file
* ***/Home/habao/test_cron.sh
# View the current cronjob
$ Crontab-l
# Do not edit this file-edit the master and reinstall.
#(/Tmp/crontab.3285 installed on Thu Sep 22 16:28:40 2011)
# (Cron version -- $ Id: crontab. c, v 2.13 1994/01/17 03:20:37 vixie Exp $)
# Display the current system time
* ***/Home/habao/test_cron.sh
# Output file time.txt
$ Cat time.txt
Thu Sep 22 12 16:33:00 CST 2011
Thu Sep 22 12 16:34:00 CST 2011
Thu Sep 22 12 16:35:00 CST 2011
Thu Sep 22 12 16:36:00 CST 2011
Thu Sep 22 12 16:37:00 CST 2011
Thu Sep 22 12 16:38:00 CST 2011
Thu Sep 22 12 16:39:00 CST 2011
To modify the current cronjob, crontab-e
To delete the current cronjob, crontab-r
Author: "To_Be_Monster_Of_IT"