Unix + OS AIX Crontab

Detailed and Linux examples in the crontab

http://darkmasky.javaeye.com/blog/224891

http://blog.chinaunix.net/u/31547/showart_438018.html

cron is a regular implementation tools under linux, you can without human intervention to run operations. Cron is a Linux built the service, but it does not automatically up, you can use the following methods to start, shut down the service:

/ Sbin / service crond start / / start the service
/ Sbin / service crond stop / / close service
/ Sbin / service crond restart / / restart the service
/ Sbin / service crond reload / / reload the configuration

You can also start the service automatically when the system starts:
In / etc / rc.d / rc.local add at the end of this script:
/ Sbin / service crond start

Cron is now inside the service has been in the process, we can use the service a, Cron service provides the interface for people to use the following:

1, directly edit the crontab command

cron service providers to set the cron crontab command service, the following are some of the parameters of this command and description:

crontab-u / / Set a user's cron service, usually root user to execute this command when the need for this parameter
crontab-l / / a user cron services listed in the details
crontab-r / / delete a user's cron service
crontab-e / / edit a user's cron service

For example, set the root view your cron: crontab-u root-l
As another example, root want to delete the cron setting fred: crontab-u fred-r
Cron service in the edit, edit, format and content of some conventions, type: crontab-u root-e
Enter vi edit mode, edit the content must meet the following format: * / 1 * * * * ls>> / tmp / ls.txt

This format is the first part of the time setting, followed by part of the command to execute if the command to execute too many commands can write a script inside, and then to go ahead and call this script on it, call When I remember to write the full path of the command. Set the time we have some agreement, in front of five * indicates five numbers, numbers, scope and meaning of values as follows:

Minutes (0-59)
Hours (0-23)
Date (1-31)
Month (1-12)
Week (0-6) / / 0 for Sunday

In addition there are several a number of special symbols is "*","/" and "-",",",* on behalf of all the figures within the range, "/" represents the meaning of each "* / 5 "that every 5 units," - "represents a number from one figure to," "a few discrete separate figures. The following few examples illustrate the problem:

6 o'clock every morning

0 6 * * * echo "Good morning.">> / Tmp / test.txt / / Note that a simple echo, not see any output from the screen, because the cron to email to any output is the root of the mailbox.

Every two hours

0 * / 2 * * * echo "Have a break now.">> / Tmp / test.txt

11 pm to 8 am every two hours between the morning and eight o'clock

0 23-7/2, 8 * * * echo "Have a good dream:)">> / tmp / test.txt

4 of each month and each week Monday to Wednesday morning 11

0 11 4 * 1-3 command line

January 1 4:00 am

0 4 1 1 * command line

Each time a user's cron editing settings, cron automatically in / var / spool / cron generate a file with this user the same name, the user's cron messages are recorded in the file, this file can not be edited directly , only can use crontab-e to edit. cron started reading once every minute over a file, check if you want to execute the command inside. Therefore, this file does not need to restart the modified cron service.

2, edit / etc / crontab file configuration cron

cron service not only to read once per minute / var / spool / cron all files, also need to read a / etc / crontab, so we can configure this file using cron service to do something. Crontab configuration is used for a user, and edit / etc / crontab is the task for the system. This file format is:

SHELL = / bin / bash

PATH = / sbin: / bin: / usr / sbin: / usr / bin

MAILTO = root / / If an error occurs, or a data output, data as e-mail sent to this account

HOME = / / / the user running the path, here is the root directory

# Run-parts

01 * * * * root run-parts / etc / cron.hourly / / hourly / etc / cron.hourly the script
02 4 * * * root run-parts / etc / cron.daily / / daily basis / etc / cron.daily script within
22 4 * * 0 root run-parts / etc / cron.weekly / / implementation of each week / etc / cron.weekly the script
42 4 1 * * root run-parts / etc / cron.monthly / / month to execute / etc / cron.monthly the script

Attention to the "run-parts" of this argument, if this parameter is removed, then back to write a script to run the name of the folder name instead.

--------------------------------------
Basic format:
* * * * * Command
Time-moon week command

Column 1 for minutes 1 to 59 per minute with a * or * / 1, column 2, said that hours of 1 to 23 (0 for 0 points)
Column 3 represents the date from 1 to 31
Column 4 represents the month from 1 to 12
Identification number of the first five weeks of 0 to 6 (0 for Sunday)
Column 6 the command to run

Some examples of crontab file:

30 21 * * * / usr / local / etc / rc.d / lighttpd restart
The above example shows the 21:30 nightly restart lighttpd.

45 4 1,10,22 * * / usr / local / etc / rc.d / lighttpd restart
The above example shows the monthly 1,10,22 Day 4:45 to restart lighttpd.

10 1 * * 6,0 / usr / local / etc / rc.d / lighttpd restart
The above example shows every Saturday and Sunday 1:10 to restart lighttpd.

0,30 18-23 * * * / usr / local / etc / rc.d / lighttpd restart
The example above indicates that 18 per day: 00 to 23: 00 every 30 minutes between restart lighttpd.

0 23 * * 6 / usr / local / etc / rc.d / lighttpd restart
The above example shows every Saturday 11: 00 pm to restart lighttpd.

* * / 1 * * * / usr / local / etc / rc.d / lighttpd restart
Lighttpd restart every hour

* 23-7/1 * * * / usr / local / etc / rc.d / lighttpd restart
11 pm to 7 am, between every hour restart lighttpd

0 11 4 * mon-wed / usr / local / etc / rc.d / lighttpd restart
4 per month, Monday through Wednesday with the 11-point restart lighttpd

0 4 1 jan * / usr / local / etc / rc.d / lighttpd restart
January 1 to 4:00 lighttpd restart

AIX system log cleaning log

http://yangbin210.javaeye.com/blog/261592
errclear command can be used to clean up the error log and the default error log clean-up cron on a daily basis
# Crontab-l
0 11 * * * / usr / bin / errclear-d S, O 30
0 12 * * * / usr / bin / errclear-d H 90
0 15 * * * / usr / lib / ras / dumpcheck>; / dev / null 2>; & 1
Obviously, looking for the above example, S, O type of error will be retained for 30 days, and H of the error for 90 days
delete multiple record errclear 0
errclear 7 7 days a previously deleted record
smit errclear

Record all error messages cron

In the / etc / syslog.conf by adding the following line
cron.err / var / cronerr.log
Cron's err definition record information to / var / cronerr.log file


IBM-AIX systems commonly used commands

http://darkmasky.javaeye.com/blog/224936

http://www.blogjava.net/luckyrobbie/archive/2006/03/27/37543.html

Close aix command: shutdown -> shutdown, shut down all services. Halt -> is equivalent to directly turn off the power.
Restart aix: shutdown-Fr

View error message:

errpt errpt-a | more -> Page Display errpt-a> / tmp/err01 output to a file.
Clear the error message:

errclear 0

See the error log on AIX systems

http://airong.javaeye.com/blog/57989

Running in the system, some system error will be recorded in the errlog, where some errors will be displayed on the terminal. Check the error log using the following command:

# Errpt | more see all the records system

IDENTIFIER TIMESTAM PTC RESOURCE_NAME DESCRIPTION

E85C5C4C 0426104399 PS CFGLFT SOFTWARE PROGRAM ERROR

2BFA76F6 0426104099 TS SYSPROC SYSTEM SHUTDOWN BY USER

9D4CF6E7 0426104399 TO errdemon ERROR LOGGING TURNED ON

1E2AC07E 0426103999 TO errdemon ERROR LOGGING TURNED OFF

1E5EER4T 0423132999 TO clstrmgr OPERATOR NOTIFICATION

Which

IDENTIFIER for the error number, if more information needs to be checked often used.

TIME STAMP as the time stamp, it records the wrong time, in the format: day month every year when the hours of sub-

T for the Type, it records the wrong type

P: permanent error, need attention

T: a temporary error.

C for the Class, it records the wrong type, such as

H: Hardware

S: Software

O: Errloger command messages

U: undetermined

RESOURCE_NAME the error sources

DESCRIPTION description of the error

# Errpt-aj <IDENTIFIER> View detailed record of the contents of the system

IDENTIFIER which is the error number, such as # errpt-aj 0426104399

# Errpt-dH view the system records all of the hardware error


# AIX regularly monitor the disk space problem of the alarm and system error log
00 02 * * * / var / snlog / dislog
00 16 * * * / var / snlog / dislog

File: dislog
Content:
#! / Usr / bin / ksh
/ Var / snlog / disfs> / var / snlog / errlog `hostname`
errpt>> / var / snlog / errlog `hostname`
lsps-a>> / var / snlog / errlog `hostname`

File: disfs
Content:
echo "==` hostname `=="
df | head -1; df | grep 100%; df | grep 99%; df | grep 98%; df | grep 97%; df | grep 96%;
printf "################################################ ########################## \ n "

File: errlogp6550b2
Content:
== P6550b2 ==
Filesystem 512-blocks Free% Used Iused% Iused Mounted on
/ Dev/fslv00 100663296 4015848 97% 8125 2% / db2data
################################################## ########################
IDENTIFIER TIMESTAMP TC RESOURCE_NAME DESCRIPTION
F7FA22C9 0917162810 IO SYSJ2 UNABLE TO ALLOCATE SPACE IN FILE SYSTEM
38A8D4BB 0825181810 IH ent0 HEA PORT DOWN
38A8D4BB 0811172110 IH ent0 HEA PORT DOWN
38A8D4BB 0713171610 IH ent0 HEA PORT DOWN
38A8D4BB 0713165310 IH ent0 HEA PORT DOWN
38A8D4BB 0713162710 IH ent0 HEA PORT DOWN
Page Space Physical Volume Volume Group Size% Used Active Auto Type
paging00 hdisk2 rootvg 3072MB 10 yes yes lv
hd6 hdisk3 rootvg 3072MB 10 yes yes lv

p6550b2/var/snlog # lsps-a
Rolls of paging space physics group size% of the automatic type of use activities
paging00 hdisk2 rootvg 3072MB 11 yes yes lv
hd6 hdisk3 rootvg 3072MB 11 yes yes lv

Linux / Unix time is set automatically restart the application (in resin as an example)

http://darkmasky.javaeye.com/blog/224906

1. First of all, the resin will not take the initiative to restart automatically load Java environment variables

So need to edit the resin / bin directory httpd.sh, configure its independent operating environment.

# Vi httpd.sh (Note: the first line into the below)

export JAVA_HOME =......
export CLASSPATH =......

export PATH =......

2. Then, edit the crontab, configure the timer.

# Crontab-e (following injection)

0 1 * * * / usr / local / resin / bin / httpd.sh restart

(1 am every day automatically restart)

(Note that the configuration of the time in which to # clock - show show time as a reference)

3. Saved, check the configuration contents

# Crontab-l

4. Restart / etc / init.d / directory crond, the configuration to take effect

# Crond stop

# Crond start

Or

# Crond restart

5. See cron log

# Ls / var / log / cron * (view the log file)

# Cat / var / log / cron (see details)

Detailed and examples on the crontab's, please refer to:

http://darkma.javaeye.com/admin/blogs/224891

end

分类:OS 时间:2010-10-11 人气:214
分享到:
blog comments powered by Disqus

相关文章

  • cron crontab linux timing of implementation tools 2010-03-29

    cron is a linux implementation of the next regular tools without the need for human intervention to run operations. Since cron is a linux built-in service, can not automatically up, can look at ways to start, close the service: / sbin / service crond

  • cron crontab linux timer implementation tools 2010-02-05

    cron is a regular implementation of the tool under linux, you can without human intervention to run operations. Since cron is built linux services can not automatically up, you can start with a look at ways to close the service: / Sbin / service cron

  • I used the Linux command dos2unix - DOS format to UNIX format text files into 2010-11-14

    I used the Linux command dos2unix - DOS format to UNIX format text files into This link: http://codingstandards.javaeye.com/blog/810900 (reprint, please indicate the source) Use Description dos2unix command to the DOS format text files into UNIX form

  • Java run-time polymorphism: inheritance and interface implementation 2010-03-29

    Java is object-oriented language, while the run-time object-oriented programming polymorphism is one of the most powerful code reuse mechanism, the concept of dynamic can be described as "one interface, multiple methods." Java run-time to achiev

  • Android UI user interface development tools (worth a try) 2010-08-28

    Recently Try tossing a few drops of real simple Android programs, the Android interface will process the UI layout (layout) with the procedure described in the application logic implementation code (code) strictly separate, and separately in res and

  • Linux sshd service to improve safety 2010-03-11

    Linux sshd service to improve safety <! - / Icon and title --><!-- message -> In the form we use Linux or Unix server, for the convenience of remote maintenance and management, basically will open sshd services. Although the ssh packets will b

  • Crontab command usage under Linux 2010-07-30

    In Linux, tasks can be configured in the specified time period, specified date, or the average system load below a specified number of hours automatically. Red Hat Enterprise Linux system pre-configured on the important task of running so the system

  • linux crontab command Detailed 2011-01-21

    This article describes the under linux cron (task scheduler) is commonly used methods. linux crontab format Basic format: * * * * * Command Time-moon week command Section 1 of minutes from 1 to 59 per minute with a * or * / 1 means that the first two

  • Crontab command using Linux system to achieve the scheduled reboot 2011-07-22

    Crontab is a very convenient in the unix / linux system timer (cycle) to perform a task of the program Use the cron service, use the cron service crond status check service status, if not start the service crond start to start it, cron service is a r

  • I used Linux command of alias - the alias command set, so that a more concise Linux command 2011-08-11

    I used Linux command of alias - the alias command set, so that a more concise Linux command This link: http://codingstandards.iteye.com/blog/1145318 (reproduced please indicate the source) Use Description Set command aliases. If the command is too lo

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.304 (s). 12 q(s)