crontab用法小结(Crontab usage summary).doc
文本预览下载声明
crontab用法小结(Crontab usage summary)
Crontab usage summary
Function: the system automatically performs an operation or task at a specified time.
Implemented by the cron daemon, the cron process is awakened every minute to see if there is an order in the crontab that needs to be executed.
Solaris is basically the same as AIX
Command format:
Crontab -e
Edit your crontab file, and if not, create a new crontab file
Crontab l.
Display your crontab file
Crontab -r
Delete your crontab file
Crontab -v
Show the time when you last modified the crontab file (only a few systems support this command)
[note 1: crontab - e does not start vi
Solution: use the EDITOR environment variable to specify the crontab EDITOR, and if you want to edit with vi, the command is as follows:
# EDITOR = vi
# export EDITOR
If it is C shell, $setenv EDITOR vi
Note 2: crontab - e automatically enables modified timed tasks;
Note 3: modify the crontab of the user. If you want to make it effective, you do not need to restart the cron process. Just use the crontab filename.
Note 4: the name of the user can be used after the command, indicating that the crontab file of the user is edited and displayed, etc., crontab - e oracle;
]
Crontab file syntax
* * * * * * * command to be executed
-- -- --
| | | | |
| | | | + - week 1-7 (Monday = 1)
| | | + -- -- -month (1-12)
| | + -- -- -day (1-31)
| + -- -- -- -time (0-23)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Note 1: do not leave the file blank at the end, or think that the end of the file will end an exception
Note 2: the timing task does not execute the specified script, but it is normal to execute the script manually
Solution: when crontab executes, the environment variable is missing, the user environment variable of the script can be added to the script correctly, or the users profile is executed at the beginning of the script.
]
Example:
1.
显示全部