`
- 浏览:
54025 次
- 性别:
- 来自:
南京
-
CRON: SCHEDULE COMMANDS
Under Linux, periodic execution is normally handled by the cron daemon. cron starts when the system boots and remains running as long as the system is up. cron reads one or more configuration files containing lists of command lines and times at which they are to be invoked. The command lines are executed by sh, so almost anything you can do by hand from the shell can also be done with cron.
A cron configuration file is called a “crontab,” short for “cron table.” cron looks for crontab files in three places: /var/spool/cron (/var/spool/cron/tabs on SUSE and /var/spool/cron/crontabs on Debian), /etc/cron.d, and /etc/crontab.
Crontab files for individual users are stored underneath /var/spool/cron. Typically, there is (at most) one crontab file per user: one for root, one for jsmith, and so on. Crontab files are named with the login names of the users they belong to, and cron uses these filenames to figure out which UID to use when running the commands that each file contains. The crontab command transfers crontab files to and from this directory.
Crontab files that schedule system maintenance tasks and other tasks defined by the system administrator are stored in the file /etc/crontab and in other files found in the /etc/cron.d directory. These files have a slightly different format from the per-user crontab files because they allow commands to be run as an arbitrary user. cron treats the /etc/crontab and /etc/cron.d entries in exactly the same way. In general, /etc/crontab is intended as a file for the system administrator to maintain by hand, whereas /etc/cron.d is provided as a place where software packages can install any crontab entries they might need.
When cron starts, it reads all of its config files, stores them in memory, and then goes to sleep. Once each minute, cron wakes up, checks the modification times on the crontab files, reloads any files that have changed, and then executes any tasks scheduled for that minute before returning to sleep.
THE FORMAT OF CRONTAB FILES
All the crontab files on a system share a similar format. Comments are introduced with a pound sign (#) in the first column of a line. Each noncomment line contains six or seven fields and represents one command:
minute hour day month weekday [username] command or
minute hour day month weekday [username] run-parts directory
The first six fields are separated by whitespace, but within the command field whitespace is taken literally. The username is found only in /etc/crontab and in files from the /etc/cron.d directory; it specifies on whose behalf the command should be run. This field is not present or necessary in the user-specific crontab files (those stored in /var/spool/cron) because the UID is implied by the filename.
The minute, hour, day, month and weekday fields tell when to run the command.
Their interpretations are shown below:
Field | Description | Range |
Minute | Minute of the hour | 0 to 59 |
Hour | Hour of the day | 0 to 23 |
Day | Day of the month | 1 to 31 |
Month | Month of the year | 1 to 12 |
WeekDay | Day of the week | 0 to 6 (0=sunday) |
Each of the time-related fields may contain:
- A star, which matches everything
- A single integer, which matches exactly
- Two integers separated by a dash, matching a range of values
- A comma-separated series of integers or ranges, matching any listed value
There is a potential ambiguity to watch out for with the weekday and day fields. Every day is both a day of the week and a day of the month. If both weekday and day are specified, a day need satisfy only one of the two conditions in order to be selected.
The command is the sh command line to be executed. It can be any valid shell command and should not be quoted. command is considered to continue to the end of the line and may contain blanks or tabs.
Eg. 20 1 * * * find /tmp -atime +3 -exec rm -f { } ';'
This command will run at 1:20 each morning. It removes all files in the /tmp directory that have not been accessed in 3 days.
CRONTAB MANAGEMENT
crontab filename installs filename as your crontab, replacing any previous version. crontab -e checks out a copy of your crontab, invokes your editor on it (as specified by the EDITOR environment variable), and then resubmits it to the crontab directory. crontab -l lists the contents of your crontab to standard output, and crontab -r removes it, leaving you with no crontab file at all.
Root can supply a username argument to edit or view other users' crontabs. For example, crontab -u jsmith -r erases the crontab belonging to the user jsmith.
Two config files, /etc/cron.deny and /etc/cron.allow, specify which users may submit crontab files. If the allow file exists, then it contains a list of all users that may submit crontabs, one per line. No unlisted person can invoke the crontab command. If the allow file doesn’t exist, then the deny file is checked. It, too, is just a list of users, but the meaning is reversed: everyone except the listed users is allowed access. If neither the allow file nor the deny file exists, most systems allow only root to submit crontabs. (Debian and Ubuntu default to allowing submissions by all users.)
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
本文讨论了软非周期任务(Soft Aperiodic Tasks)在硬实时多处理器系统(Hard Real-Time Multiprocessor Systems)上的调度问题。硬实时系统是指必须满足严格的时限要求的系统,而软非周期任务则是指那些没有固定...
该策略被称为PLUFS(Periodic Tasks with Largest Utilization First based on Switching Overhead),它特别考虑了处理器状态切换的开销,这是传统方法通常忽视的一个关键因素。 在嵌入式实时系统中,处理器状态...
- **Scheduling Periodic Messages:** Scheduling periodic messages is useful for implementing recurring tasks. - **Template Pattern:** The Template Pattern provides a way to define common behaviors for ...
- Kernel timers are used for scheduling periodic tasks and timeouts. This section explains how timers are implemented and managed in the kernel. 7. **Bottom Halves (Section 2.7):** - Bottom halves ...
// $Id: INSTALL.txt,v 1.61.2.4 2008/07/09 19:15:59 goba Exp $ CONTENTS OF THIS FILE --------------------- * Requirements * Optional requirements * Installation ...7. CRON MAINTENANCE TASKS...
Timer and Periodic Tasks - **定时器**: 提供了设置固定延迟或周期性任务的功能。 - **使用示例**: - **单一延迟**: 设置一次性延迟执行的任务。 - **周期性任务**: 定义重复执行的任务。 #### 5. HTTP ##### A...
`Timer`类提供了两种类型的定时任务:一次性任务(One-Time Tasks)和周期性任务(Periodic Tasks)。一次性任务只执行一次,而周期性任务则会按照设定的间隔重复执行,直到被取消。 1. **创建Timer对象** 要使用`...
5. **Periodic Tasks**:Celery 支持周期性任务,如定时任务。 6. **结果后端**:存储任务执行的结果,例如 Redis 或数据库,以便查询任务状态。 7. **错误处理和监控**:如何在 Celery 中捕获和处理异常,以及使用...
2. **添加计划任务**:通过访问`http://localhost:8000/admin/`进入管理界面,在Celery的管理页面里选择Periodic Tasks,然后添加新的定时任务。在这个过程中,你需要选择相应的任务并设置定时或周期时间。 3. **...
在详细解释这篇文章所涉及的知识点之前,首先需要明确几个关键概念:实时系统(Real-Time Systems)、非周期性任务(Aperiodic Tasks)、利用率准入控制(Utilization-based Admission Control)以及最早截止期限...
本篇研究论文的核心内容是介绍一种针对具有约束截止期的周期性实时任务的工作量感知谐波分区调度方案(Workload-Aware Harmonic Partitioned Scheduling),该调度方案适用于在固定优先级抢占式调度策略下的多处理器...
is to understand how the SysTick as the Hardware Timer can be used to provide a periodic interrupt for a Real Time Operating System (RTOS). For simplicity purposes, the GPIO pins will be used in this ...
celery_example 具有周期性任务的celery-app的结构示例启动命令: $ pip install -r requirements.txt $ celery -A main_app.periodic_tasks beat $ celery -A main_app worker Python 3.6
例如,使用`result_backend`配置存储任务结果,使用`@periodic_task`装饰器创建定时任务,或者利用`on_failure`回调处理异常。 综上所述,“django+celery实战”涵盖了异步任务处理、Celery与Django的集成、...
通过`<periodic_tasks>`标签,可以配置定时任务,如发送邮件、定期执行脚本等。每个`<periodic_task>`标签包含类名(如`class_name`)和启动参数(如`start_on_running`),以及时间定义(如`<time_def>`),用于...
在实时系统中,调度理论和资源访问协议都得到了广泛的研究。 然而, 对于具有共享资源的实时系统的调度算法,研究非常有限。 随着多核处理器的出现,这一点变得更加突出。 本文着重于分区EDF调度和MSRP 资源访问协议...
"Scheduling Multi-Periodic Mixed-Criticality DAGs on Multi-Core Architectures.pdf"则深入到混合关键性的多周期任务调度问题。在多核架构上,处理具有不同优先级和截止日期的任务图(DAG)是一个挑战。该文档...
This article aims to provide an overview of the daily, monthly, and periodic maintenance tasks required to ensure the reliability and efficiency of hospital databases. 1. 数据库日常运维内容 数据库...
DFT, on the other hand, is a mathematical tool used to convert a time-domain signal into its frequency-domain representation, revealing the frequencies that make up a periodic signal. In the context...