Linux routine work scheduling

Source: Internet
Author: User

1. There are two ways of routine scheduling:

1) Every certain period to do things, with the crontab instructions to achieve

2) Sudden, this is done, there is no use at the command to achieve, but this need to ATD service support

2.linux Common routine tasks are:

1) The rotation of the login file: Linux will record all the information that happens in the system, this is the login file, as the system runs these log files will become larger and higher, resulting in decreased system read and write performance, so you need to store these data by the old and new time, this is the rotation of the log file task

2) Login File Analysis: If the system has a software problem, hardware errors, resource security issues, and so on, most of the errors will be logged into the log file, so one of the important tasks of the system administrator is to analyze the login document. But you can not manually monitor the login file through vim and other software, because the data is too complex, so the system provides logwatch this program, to actively analyze the login information.

3) Locate database establishment: stored in the/var/lib/mlocate, the system will be active in the specified time call updatedb This command, update the database

3) Establishment of Whatis database

4) Establishment of RPM software login file: RPM is a software management mechanism. Because the system may often change the software, including the new installation of software, non-recurring updates, etc., will cause the software file name differences. In order to facilitate future tracking, the system also helps us to make a sort of file name records. Sometimes the system also helps to reset the RPM database by scheduling.

5) Remove the temporary archive: the software run will produce some temp files, but after the software is closed, these temporary files may still exist, if beyond a certain period of time, the scratch disk is useless, it is an important task to remove these scratch disks. Otherwise the disk will be consumed quickly.

6) Network Service-related analysis behavior: if the WWW web site service software is installed, Linux usually proactively analyzes the software's login files. At the same time, some of the credentials and authentication network information is out of date, our Linux system will also help us check

3.ATD start and at operation mode:

1) Starting mode:/etc/init.d/atd Restart (start, stop)

2) at operating mode:

A) First find/etc/at.allow This file, written in this file users can use at, no users in this file can not use at

b) If/etc/at.allow does not exist, look for/etc/at.deny this file, if it is written in this At.deny user can not use at, but not in this At.deny file users, will be able to use at this command

c) If none of the two files exist, then only root can use the AT command

3) Usually the system default all users are trustworthy, so the system will usually keep an empty/etc/at.deny file, but in case you do not want some users to use at command, the user's account will be written to/etc/at.deny, an account line

4.at [-MLDV] time;at-c work number: Single work schedule, parameters,

1) at the completion of the work, timely no output information, but also to the user e-mail to inform users that the work has been completed

2) The alias of the-L:ATQ, which lists all the user's at schedules on the current system

3)-d:at-d equivalent to ATRM, can cancel a work in the at scheduling

4)-V: You can use the more obvious time format to list the taskbar table in the at schedule

5)-C: You can list the actual instruction content of the work after it.

6) Time: format, where you can define the time at which the

HH:MM, at today's hh:mm moment, if that moment is over, then this point of tomorrow will do the work

HH:MM YYYY-MM-DD, which enforces the work at a particular time of day of the month of the year

HH:MM[AP|PM] [month][date], mandatory in the current year, the specified month day

Hh:mm[ap|pm]+number[minutes|hours|days|weeks], you can use now to refer to the current time, that is, how long it takes to perform the operation after a certain time.

7) When we use at will enter a Atshell environment to let the user to release the work order, at this time, it is advisable to use absolute path to release your instructions, relatively stable, because the command is released with the path variable, and also related to the working directory at the time. At runtime, it runs to the working directory where the AT command was issued to execute the instruction.

8) Release echo "Hello" at the AT command. Does not appear on the screen, because the execution of at is related to the terminal environment and is not related to standard output or standard error output, if you want to see the information on the terminal by the echo "Hello" >/dev/tty1 this command to achieve.

9) due to the use of the at work scheduling, the system will be independent of the project in your bash environment, directly to the system's ATD program to take over, so when you release at the work can be immediately offline, the rest of the work to Linux management. If you have a long network management job, using at can help you avoid network disconnection.

5.batch: Background task is only available when the system is empty. Batch is the release of instructions using at. Just added some control parameters. This batch will work as you work on the task when the CPU workload is less than 0.8. Load refers to the amount of work the CPU is responsible for per unit time (number of processes), different from CPU utilization, such as a program he needs to always use the CPU's computing function, then the CPU utilization rate may reach 100%, but the CPU workload is approaching 1, if you execute two programs at the same time, The load is 2

So the load on the CPU reflects how many different jobs the CPU needs to switch between.

6. Cyclic execution of routine work scheduling: controlled by the cron (Crond) system service, which can also be used to limit the use list of the service through/etc/cron.allow,/etc/cron.allow. When the user uses the Crontab command, the record is recorded in the/var/spool/cron/and is determined by the account number. For example, huge performed the crontab command, and his work was recorded in/var/spool/cron/huge. Do not edit the file directly using VI, however, because you may enter a syntax error. Will cause the cron to fail to execute. In addition, every job that Cron performs will be recorded in the/var/log/cron log file, so you can follow this file to see if a Trojan horse is implanted.

7.crontab [-u username] [-l|-e|-r]: Loop execution routine task, parameters

1)-U: Only root can perform this task, that is, to help other users to set up/remove crontab work schedules

2)-E: Edit Crontab's work content

3)-L: Check the crontab's work content

4)-R: Remove all crontab work, if only one item is removed, use-e is better.

Each directive has six fields, meaning: Minute (0-59), hour (0-23), date (1-31), month (1-12), Week (0-7), directive. 0 and 7 of them all represent Sunday.

There are also some auxiliary characters:

A) *: means accepted at any time.

b): Represents the meaning of the split window, such as 3 to 6 points, then: 0 3,6 * * command

C)-: Represents a period of time, such as 8 to 12 hours per hour of 20 minutes to do a job: 8-12 * * * command

D)/N (slash): N denotes a number, i.e. the meaning of every n unit interval, for example, every 5 minutes, then: */5 * * * * command.

8./etc/crontab: System configuration file, Crontab-e is designed for the user's cron, if it is a system routine task, only need to edit. etc/crontab this file, cron. The minimum detection limit for this service is minutes, So Cron will go to read/etc/crontab and/usr/bin/crontab This file every minute, so as long as you edit/etc/crontab this file, and save it, then the cron settings will be automatically executed.

Viewing the file will find a path that represents the execution file search path, Mailto=root: For additional stdout, the data will be emailed to the specified user.

/etc/crontab This file supports two kinds of command release methods:

1) instruction type, which is directly followed by instructions

2) directory planning, using the Run-parts directive, the script to be executed is placed under this directory, you can

9. Some considerations:

1) Uneven allocation of resources, including traffic, traffic detection of other PCs in the region, CPU utilization, RAM usage, online people real-time detection.

2) Cancel items that you do not export

3) Safety monitoring, on the/var/log/cron line to see the Trojan

4) Zhou and sun cannot coexist

10.anacron: Handle the crontab of Linux systems that are not 24 hours long, so Anacron does not specify the appropriate task to perform, but in days or immediately after the start of the Anacron action, He will be able to detect crontab tasks that should be performed during the outage, but do not perform the task again, and the Anacron will stop automatically.

Anacron is actually a program, not a service.

11.anacron [-SFN] [job];anacron-u [job]: parameters,

1) Start a continuous execution of each job (job), based on the data of the time record file to determine whether

2)-F: Enforced without judging the timestamp of the event log file

3)-N: Perform an unfinished task immediately without delaying the wait time

4)-U: Update timestamp of time log file only, do not do any work

5) Job: The name of each job with/etc/anacrontab definition

12. When we release the anacron instruction, it will operate:

1) The number of days from/etc/anacrontab analysis to cron.daily This job name is 1 days

2) The timestamp of the most recent execution of the Anacron was taken out by/var/spool/anacron/cron.daily

3) from the previous step compared with the current time, if the difference in number of days is set more than the number of days (including this day,/etc/anacrontab's first parameter) is ready to carry out the directive

4) The number of minutes (the second parameter of/etc/anacrontab) will be set according to the/etc/anacrontab setting, if the instruction is prepared.

5) After the delay time, the following instructions are executed, i.e., the instructions behind the Run-parts

6) Execution complete, anacron program end

13.chkconfig--list Anacron: Check to see if Anacron is actively executing the boot.


This article is from "Tiger Brother's Blog" blog, please be sure to keep this source http://7613577.blog.51cto.com/7603577/1598577

Linux routine work scheduling

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.