Linux task management with Margo Linux (Lesson 5)

Source: Internet
Author: User

1.linxu Task Scheduler:

Task Schedule:

Perform a task at a future point in time: At,batch

Recurring tasks: crontab

e-Mail Service:

Smtp:simple Mail Transmission protocol

/var/spool/mail/username Personal Mail Buffer directory

Pop3:post Office Protocol

Imap4:internet Mail Access Protocol

Mua:mail command

Mail

Mail: Enter the interactive send and receive mail interface

Mail-s "SUBJECT" [email protected]

Mail-s "SUBJECT" [email protected] < echo "AAA"

Command | Mail-s "SUBJECT" [email protected]


AT command:

Commands to host future executions

Execute using Job queue

Default to a queue

Crtl+d

at [option].. Time

Time command:

1. Absolute time hh:mm Mmdd[cc]yy

2. Relative Time now+ time

Minut Hour day Week

3. Blur Time

Midnight Noon Teatime

Common options:

-Q queue at job queues

-f/path/filename read the developed file job from the specified file

-L View the list of running jobs in the job queue, equivalent to the ATQ command

-C At_job_num to get the details of the task to be job

-d Deletes the specified command job, equivalent to ATRM

Batch

The system chooses to run the specified task when the resource is idle

Crontab: Periodic execution of Mission plans

Daemon: Crond

There are two types of recurring tasks:

(1) System cron Task: The user identity is not run by default, so you need to specify additional running

/etc/crontab

Vim command

7 fields

Top 5 fields: Time field

Username: which user to run

Command: Run the order

(2) User Cron Task: Submitted by a user, run as submitter by default

/var/spool/cron/username

Vim command:

7 fields

Top 5 fields: Time field

Username: which user to run

Command: Run the order

5 Time points:

First field minute: Domain 0-59

Second field hour: domain 0-23

Third Field Day: Range 1-31

Fourth field month: Domain 1-12

Fifth field week: Domain 0-7

Note: It is not recommended to use both days and weeks of the month

Time notation:

Number: Indicates a specific point in time

*: At each point in time valid value range

-: A continuous time range, e.g. 3-7

,: A discrete time range, such as 3,5,7

/: How many times in the effective time range, specify the frequency of execution

crontab command

crontab [-u user]-l-r-E

-u User: Not running your own cron task, only administrators have permissions

-L: List cron tasks

-r: Delete cron task

-E: Edit cron Task


Supplemental tool: Anacron check for last cron not functioning automatically

Note: If you do not want to receive messages that command run results

COMMAND >/dev/null

Commadn &>/dev/null

For crontab file% there is a special meaning to use transfer escapes

Crontab's path variable is not exactly the same as the user environment variable and requires an absolute path

Practice:

1, every Monday to Saturday 3:20 A.M., run the tar command to backup the/etc directory, the backup directory is/BACKUP/ETC-YYYY-MM-DD.TAR.XZ

2, every Sunday 2:30 A.M., run the CP command to backup the/etc/fstab command, the backup path is/BACKUP/FSTAB-YYYY-MM-DD-HH-MM-SS

3, every night 12 o'clock, get all the lines in the/proc/meminfo file starting with S or M, append to the middle of/static/meminfo.txt to =============== as the delimiter.


1.[[email protected] ~]# CRONTAB-E20 3 * * 1-6 tar-czvf/backup/etc-$ (date ' +%f '). Tar.gz/etc/2. [[email protected] ~]# CRONTAB-E30 2 * * */* cp/etc/fstab/backup/fstab-$ (date ' +%f-%h-%m-%s ') 3. [Email protected] ~]# CRONTAB-E0 * * * echo "================================================" >>/statistics/ Meminfo.txt && Cat/proc/meminfo | Grep-e ' ^s|^m ' >>/statistics/meminfo.txt


Linux task management with Margo Linux (Lesson 5)

Related Article

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.