System Administrator Toolkit: Time and Event management

Source: Internet
Author: User
Tags time interval disk usage

About this series

Often, the UNIX® administrator has a set of utilities, techniques, and systems that he or she often use to assist in the management process. Provides a variety of key utilities, command line chains, and scripts for simplifying different processes. Part of these tools comes from the operating system, and most of the techniques come from long term experience and simplifying the requirements of the system administrator. This series of articles focuses on maximizing the tools available in various UNIX environments, including ways to simplify management tasks in heterogeneous environments.

Plan in time to manage

A typical system administrator spends a lot of time doing repetitive tasks. They do this, at least in the absence of a task scheduling system that can run various tasks at the right time.

Typical examples include daily tasks such as running backups, and various tasks to be performed on a weekly or monthly basis, such as cleaning up daily values, generating reports, and a large number of other commands to be executed in various situations.

There are other tasks that you want to run at a specific time interval, such as a command to monitor a currently running process or a list of current disk usage, all of which can be used to help diagnose and identify problems when a failure or other problem occurs. Alternatively, there may be commands that you want to execute at a specific time when you are not present. For example, you might want to shut down a computer that prepares for work the next day at night, but you may not want to wait until midnight just to shut down your computer.

There are solutions available for all of these situations, but before you know how to do this, you should be aware of some of the drawbacks and deficiencies of the planning approach.

Because all tasks are automated, one of the major issues in the execution of the plan is that if any errors or contingencies occur, there is no opportunity to resolve the problems that arise. In addition, you are completely dependent on the system and its ability to perform specific tasks at specific times. There are some restrictions on when the command is to be executed, and unpredictable scenarios like "execute Y if x is executed, or Z" are required for scripting, and many tests may be encountered.

However, planning can save a lot of time, so these options are worth considering.

Scheduled tasks for one-time execution

The cron system handles all the time based command execution plans and provides two different solutions that can be used to run commands at specific times. The AT command schedules a task to be performed at a specific time and only once. The crontab system allows you to specify the execution plan for a command, run at a specified time, run on a specific day, or use it in combination.

The AT command can be used in two ways. The first is to type at the at and the time you want the command to run (you can choose to specify a date). For example:

$ at 17:20
echo It's 17:20!
job 1 at Tue Apr 11 17:20:00 2006

When you enter the AT command, it waits for you to enter a command to run at a specified time. You can enter any number of commands that will be executed as Shellscript. To terminate the input, use the End-of-file command (usually control-d).

The command you type will be executed in a copy of the environment that invokes the AT command. This means that your active PATH, library, and other environment settings will be logged and used to execute the script that you generated. The results are usually emailed to you when the command is complete.

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.