后来查了Solaris的crontab的手册,发现Solaris的crontab不支持MAILTO,必须要用mailx之类的Unix邮件发送命令。另外,整个cron file只要一句话:minute(s) hour(s) day(s) month(s) weekday(s) command(s). 比如:
=========================================================================
Thecrondaemon is a long running process that executes commands at specific dates and times. To schedule one-time only tasks withcron, useatorbatch. For commands that need to be executed repeatedly (e.g. hourly, daily or weekly), usecrontab, which has the following options:
crontab filename | Install filename as yourcrontabfile. |
crontab -e | Edit yourcrontabfile. |
crontab -l | Show yourcrontabfile. |
crontab -r | Remove yourcrontabfile. |
[email protected] | Emails the output to the specified address. |
Thecrontabcommand creates acrontabfile containing commands and how oftencronshould execute them. Each entry in acrontabfile consists of six fields, specified in the following order:
The fields are separated by spaces or tabs. The first five are integer patterns and the sixth is the command to be executed. The following table briefly describes each of the fields.
minute | 0-59 | The exact minute that the command sequence executes. |
hour | 0-23 | The hour of the day that the command sequence executes. |
day | 1-31 | The day of the month that the command sequence executes. |
month | 1-12 | The month of the year that the command sequence executes. |
weekday | 0-6 | The day of the week that the command sequence executes. Sunday=0, Monday = 1, Tuesday = 2, and so forth. |
command | Special | The complete command sequence variable that is to be executed. |
Each of the patterns from the first five fields may either be an asterisk (*) (meaning all legal values) or a list of elements separated by commas. An element is either a number or two numbers separated by a minus sign (meaning an inclusive range). Note that the specification of days may be made by two fields (day of the month and day of the week). If both are specified as a list of elements, both are followed. For example:
Thecrondaemon would run the programscriptname.cgiin thecgi-bindirectory on the first and fifteenth of each month, as well as on every Monday. To specify days by only one field, the other field should be set to *. For example:
The program would then only run on Mondays.
If acronjob specified in yourcrontabentry produces any error messages when it runs, they will be reported to you via email.
You may createcrontabfiles in notepad (being sure to upload them in ASCII) or you may create them withintelnetby simply typing:
For more information, consult the man pages. man pages are the directions and tutorials available to you right at the command line from withintelnet. Type any of the following lines to open the relevant tutorials:
Note:
Yourcrontabfilemustend with a line feed - in other words, make sure to press [Enter] after the last line in the file.
Now that you have read an overview ofCron, test your skills by following the steps below. Once completed you should have acronfile of your own!
Step 1:Create a simple text file using Notepad or any simple text editor that contains the following text:
Notes for Step 1
Step 2:Name the text file. (Example: cronfile.txt)
Thecronfilename may be replaced with any name you choose. For instance if you are running aCronto trigger an email reminder script it could be calledreminder.txt. Many choose to simply call it cronfile.txt.
Step 3:Upload the file inASCII.
Any standard FTP client or your account'sCNCupload feature will work for this. It must be uploaded inASCIImode and it is recommended that it be placed in your/big/dom/xdomain/directory. It may be placed anywhere in your account but to prevent browser access (security risks) it is strongly recommended to place it above your /www directory.
Step 4:Telnetinto your account and issue the following command:
The above tells the server'scrontabwhere the file is located and that you wish to make it active. Make sure the path to the file is the actual path to where the file was placed. If successful you will be returned to the command bash line, if not an error will be displayed)
IMPORTANT NOTES
Removing/Stopping the Cron: Deleting thecronfile.txtfile from your account willnotstop thecron. You may remove this file at any time, since the server'scrontabalready has the contents, and thecronwill still run after you have made it active.
To turn thecronoff you mustTelnetinto your account and issue the following command:
Thecrontab -rwill deactivate thecronjoband remove the file contents from the server.
Security Note:If the script thecronis setup to run is in the /cgi-bin/ or /www/ directory it may be run at anytime by anyone with browser access. If thecrontabis all that should run the script and you do not want the public to be able to run the script, then you will need to place the script in a directory above the /cgi-bin/ and /www/ directories such as:/big/dom/xdom/user/cronscripts/scriptname