Recurring Task Scheduler and cron

Source: Internet
Author: User

First, Mail Sending and receiving

Service start or Not status View: Netstat-nlptu "25" Port SMP service OK

The default send and receive messages can only be made between users on this computer, and only through the address on the loopback interface

Mail

Receive mail: Mail

Q: Exit

N: View Nth message

To send an email to a specified user:

Mail username[@HOSTNAME]

-S "SUBJECT"

echo | Mail


Ii. Linux Task Plan

One-time mission plan: At,batch

Recurring Task Scheduler: Cron


At:

at time

Submit Task: Crtl+d

Job Result: Send the current user on the system as a message

Put at the left and right of the task at the execution of the stable, let at read this file as to run the task

At-f/file Time


Format of Time:

Precise time: hh:mm

Blur time: now+ #UNIT Noon (12 points) Midnight Teatime (16:00) tomorrow+

Job Queue view:

At-l,atq

Delete a job that has not been run at-d Jobnum, ATRM


Bath: No time is required and will automatically run at a later point in time for a system resource to be idle



Cron:

rely on background services to view the status of a running service Crond

There are two types of cron tasks:

System cron:/etc/crontab

User cron: Defined in a file with the same name as the user name in the/var/spool/cron/directory


1. Define a separate task for each line

2, it is recommended that when you define a cron task, the command used to use the absolute path, if the script, the command in the script to use absolute path, or to customize a complete environment variable

Format: Point in Time (recurring task) User-name: User identity command: The task to run

Point in time:

Minutes hours days months weeks

4 7 3 2 per year *

20 18 6 per month * *

20 9 per day * * *

3 per hour * * *

Per minute * * * * *

16 17 * * 3 per week

1. Each time bit should use its available valid range of values, * indicates the use of all its valid values

2, */#在对应的时间位有效值上每 # time Unit once

*/3 * * * * NOTE: It is not possible to do this exactly once every 3 minutes

* */3 * * *? * */3 * * *

40 3 * 1-5

40 3 * * 2,4,7

The result after the task is run, the message is sent to the task related user; Discard message notification: Output REDIRECT Command>/dev/null


Definition of User cron task: syntax errors are checked automatically,

crontab command:

-L Lists all tasks for the current user

-e Open the Edit Interface definition task

-R Removing All Tasks

-U USERNAME manage specified user crontab

Note: If you need to use "%" in the user command in crontab to escape with "\"

Definition of System cron:

Edit the/etc/conttab file directly to

Anacron: Provides a complement to cron:

Recurring Task Scheduler and cron

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.