但是我按照这篇文章的介绍,在Solaris 9下设置crontab的文件时,老是报错
后来查了Solaris的crontab的手册,发现Solaris的crontab不支持MAILTO,必须要用mailx之类的Unix邮件发送命令。另外,整个cron file只要一句话:minute(s) hour(s) day(s) month(s) weekday(s) command(s). 比如:
=========================================================================
What is acronjob, and how do I use it?
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. |
MAILTO=user@domain.com |
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:
minute(s) hour(s) day(s) month(s) weekday(s) command(s)
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.
Field
Value
Description
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:
MAILTO=user@domain.com
0 0 1,15 * 1 /big/dom/xdomain/cgi-bin/scriptname.cgi
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:
MAILTO=user@domain.com
0 0 * * 1 /big/dom/xdomain/cgi-bin/scriptname.cgi
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:
man 5 crontab{enter}
man 1 crontab{enter}
man cron{enter}
man at{enter}
man batch{enter}
man 1 cron{enter}
Note:
Yourcrontabfilemustend with a line feed - in other words, make sure to press [Enter] after the last line in the file.
Try It!
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:
MAILTO=yourusername@yourdomain.com {Enter}
58 23 * * * /big/dom/xdomain/cgi-bin/yourscript.pl
{Enter}
Notes for Step 1
- You may create this file using yourCNCFile Manager by navigating to the /big/dom/xdomain/ directory and clicking 'Create New File' or any other simple text editor such as Notepad.
- {Enter} should not actually be typed. [Enter] means hit the {Enter} (return) key to begin the next line and to add a blank line feed at the end of the last line of yourCronFile. It is important to always remember to do this.
- MAILTO: Replace the email address with a valid email address of your own. This will ensure that when yourcronruns, that any output from the script, such as error message, will be emailed to you.
- The second line tells your server when to run this script. In this example, the script will be run at 11:58 PM Eastern Time every day of the year.
- It is very important that you double check the script path to ensure it is correct and remember the file names are CaSe SeNsiTive.
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:
crontab/big/dom/xdomain/cronfile.txt
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
分享到:
相关推荐
在Linux中,Cron Job通过`crontab`命令进行管理和配置。 **1. `crontab`命令** - `crontab -l`: 此命令用于列出当前用户的Cron Job设置,显示所有已存在的定时任务。 - `crontab -r`: 用于删除当前用户的全部Cron ...
- 在Linux系统上,可以通过编辑`crontab`文件来添加新的Cronjob条目。例如,要每小时执行一次`runcronjobs.php`,可以在`crontab`中添加如下命令: ```bash 0 * * * * /usr/bin/...
Plan 是一个简单化管理 crontab 和 cronjob 的 Python 库。Plan 是编写和部署 cronjob 的 Python 库,能把 Python 代码转换成 cron 语法的代码。用户可以轻松的管理 cron job。 主要特性如下: 只需一个命令就可以...
在Linux环境中,Cronjob是系统定时任务调度器,它允许用户或系统管理员安排定期的任务执行。本教程将深入探讨如何使用Cronjob配合其他工具,如mysqldump(用于MySQL数据库备份)和AWS CLI(Amazon Web Services的...
同时,CronJob则是在特定时间点执行周期性任务的控制器,类似于传统的Linux crontab。 **Job的详细说明:** 1. **spec.template**:Job的Pod模板,与Pod的定义类似,包含了Pod的容器、镜像、命令等配置。 2. **...
Cron Job的设置主要通过`crontab`命令来完成,该命令有多个子选项用于不同的操作。 1. `crontab -l`:此选项用于列出当前用户的所有cron任务。你可以通过运行这个命令查看已经设置好的定时任务列表。 2. `crontab ...
本教程将深入探讨如何在ThinkPHP 5.1中配置和使用Crontab计划任务,即think-cron功能。 一、ThinkPHP 5.1中的定时任务 在ThinkPHP 5.1中,定时任务通常被称为计划任务,它们允许开发者设置定期执行的任务,而无需...
一个简单的Web界面,可轻松生成cron表达式。 贡献 随意建议功能或打开拉取请求。 在本地运行 $ git clone git@github.com:cronhub-app/crontab.git $ cd crontab $ yarn $ yarn start 在浏览器中查看运行的应用...
网站备份用于备份网站文件和数据库的 Bash 脚本##安装: 将备份文件放入脚本文件夹设置选项:您的数据库用户、数据库密码、要备份的文件夹、要备份的数据库保存您的更改创建一个 cronjob (crontab -e) 并添加类似...
通过编写 crontab 文件(cron job),用户可以指定某个脚本或命令在特定的时间点自动运行。 #### 二、crontab命令格式 `crontab` 命令的基本格式为: ```bash crontab [选项] [文件] ``` 其中主要的选项包括: - `...
4. 在命令行环境下创建cronjob,即在服务器的crontab中添加相应的定时任务。比如,如果我们要每300秒(5分钟)执行一次任务,可以添加如下条目: ``` 300 *** /usr/bin/...
- 另外,可以配置输出到特定的日志文件,如`>>/var/log/cronjob.log 2>&1`。 请注意,不同的Unix或类Unix系统可能会有一些语法差异,如某些版本的Unix不支持星号表示的步进值,此时需要使用列举的方式定义间隔。 ...
-cron MongoDB集合为crontab 该软件包提供了一个简单的API,用于计划任务和在集合上运行重复性作业。 任何集合都可以转换为作业队列或crontab列表。 它使用官方支持的。 它速度很快,最大程度地减少了处理开销,并且...
crontab 是 Yii 框架的扩展,有助于添加系统 cron 作业。 它还支持应用程序控制台命令。 $ cron = new Crontab ... // erase all previous jobs in my_crontab// Application console job$ cron -> addApplicationJob
cron = CronTab(user=True) # 获取当前用户的crontab job = cron.new(command='echo "Hello, World!"') # 创建一个新的任务 job.every(1).hours() # 设置任务每小时执行一次 cron.write() # 将更改写入crontab...
CronJob是基于传统的Linux crontab概念设计的,它将cron定时任务的概念引入了Kubernetes集群。通过创建一个CronJob对象,你可以设置一个作业何时启动、多久启动一次,以及如何处理并发运行的实例。这使得系统能够...
var job = crontab . create ( 'ls -la' , '0 7 * * 1,2,3,4,5' ) ; // create with Date var job = crontab . create ( 'ls -lh' , new Date ( 1400373907766 ) ) ; // create with comment var job = crontab...
hubot-cron向hubot添加了cronjob系统,以在特定日期和时间安排消息。 安装 将hubot-cron添加到您的package.json中,运行npm install并将hubot-cron添加到external-scripts.json 。 将hubot-cron添加到您的package....
0481-095 The cron job is being rescheduled.` - 错误代码:`!cron:0481-087 The cqueue maximum run limit has been reached.` 这些错误提示表明cron作业队列已达到最大运行限制,因此无法再接受新的作业。 ####...