Http: // 10.1.1.35/ule_basic/ule08.txt

Source: Internet
Author: User
Tags set time custom name
--

Time task

At crontab anaron



At
1. The task is a one-time task.
2. After the set time point expires, the task cannot be executed again.


/Etc/init. d/ATD start -- start the corresponding service


Chkconfig ATD on -- level 2345


[Root @ Li ~] # At 042510 -- executed at on January 10, April 25
At> echo 'hello'>/dev/pts/2
At> <EOT> -- press Ctrl + D to end
Job 15 at -- we can see when the job will be executed



At
-L viewing the time job is equivalent to ATQ
-D: The deletion time job is equivalent to atrm.
-C: display the time job content
-F is followed by a script

The/var/spool/at directory stores your at tasks that have not been executed.

[Root @ Li ~] # Ls/var/spool//
A%e01bf7989 a00011014b8c0e a00012015396ce -- here we can see that there are three at tasks not executed

[Root @ Li ~] # File/var/spool/AT/a%e01bf7989
/Var/spool/AT/a%e01bf7989: Bourne shell script text executable

[Root @ Li ~] # Cat/var/spool/AT/a%e01bf7989 -- the content of this at task is the same as that of at-C.

[Root @ Li ~] # ATQ
18 A root
14 2025-10-04 a root
17 A root

-- Execute the task for a period of time from now on.
[Root @ Li ~] # At now + 1 minutes -- units include minutes, hours, days, and weeks
At> echo 'bbb '>/dev/pts/2
At> <EOT>
Job 19 at -- the time and Task Number of the job to be executed are also displayed.


[Root @ Li ~] # At 042510-f at. Sh -- use the-F parameter to connect to the script program to be executed
Job 20


Restrictions on the Use of at tasks:
/Etc/at. allow
/Etc/at. deny

/Etc/at. allow -- here, you can write a common user that allows at execution, one row of a user; if it exists, you don't have to consider at. deny.
/Etc/at. deny -- here, you can decide to reject normal users who execute at, one row of users; if at. allow does not exist, it takes effect.


-- The default system has only one/etc/at. deny and is empty. That is to say, all common users of the default system can use the at service.



Batch executes commands when system load levels permit; in other words,
If the load average drops below 0.8, or the value specified in
The invocation of Atrun.

Batch command
It is executed only when the load is less than 0.8. The usage is the same as.



-- $ $ $


Crontab


Crontab features:
1. Periodic Operation
2. If the time passes, the task will not be executed. The task will be executed again in the next cycle.


[Root @ Li ~] #/Etc/init. d/crond start -- start the corresponding service. Note that the service name is crond rather than crontab.

Configuration file;/etc/crontab -- General Directory setting
Shell =/bin/bash
Path =/sbin:/bin:/usr/sbin:/usr/bin
Mailto = root
Home =/

# Run-Parts

Execution cycle time execution identity command line Directory
01 *** root run-parts/etc/cron. Hourly
02 4 *** root run-parts/etc/cron. daily
22 4 ** 0 root run-parts/etc/cron. Weekly
42 4 1 ** root run-parts/etc/cron. Monthly


Time Format
Minutes, days, months, and weeks
01 ****

Minute: 0-59
Hour: 0-24
Day: 1-31 depends on the month
Month: 1-12
Week 0-7 0 and 7 both represent Sunday

Several special symbols in time format
* Represents every minute, every hour, every day, every week, every month ..........
, Representing the separation time
-Represents a time range of 7-20
/N indicates every n units/3



01, 5, 12, 18, 23 *** -- the first minute
01*5-15 ** -- the first minute of every hour from the 5th to the 15th of each month
/2 ***** -- every two minutes
/3, 1, 8, 1, 5, 3, 6, 7 -- every three minutes of, 8, from to, January 1, June (only Sunday)



Which user is used to execute the execution identity? Note that the execution identity must have the execution permission.


Run-parts -- usually followed by a directory, which indicates all
[Root @ Li ~] # Which run-Parts
/Usr/bin/run-Parts


Example 1;
Vim/etc/crontabcrontab-e-u d

* *** Root echo 'crontab'>/dev/pts/2 -- each minute, a crontab is echo to the/dev/pts/2 terminal.


Example 2;
Vim/etc/crontab
* *** Root run-parts/etc/cron. minutely -- create a directory that will be executed every minute. Put the script tasks to be executed every minute in this directory. Be sure to have the execution permission.


Note:
-- After the configuration of/etc/crontab is modified, the crond service does not need to be restarted, but it must be enabled.


Command setting method:

Crontab
-E -- edit your own time task
-L -- list your own time tasks
-R -- delete a time task
-I -- confirm before deletion

[Root @ Li ~] # Crontab-e
30 18 ***/sbin/init 0 -- write it to automatically shut down at 06:30 every night. Note that it is valid only when written by the root user.


[Root @ Li ~] # Crontab-l -- list your own time tasks
30 18 ***/sbin/init 0


[Root @ Li ~] # Crontab-r -- delete all your time tasks. to delete only one or two rows, manually delete them.

Crontab task
/Var/spool/cron/* -- * indicates the user


Use root users to manage normal users' time tasks
Crontab-e-u d -- edit the time task of D citizen
Crontab-l-u d -- list the time tasks of D users
Crontab-r-u d -- delete the time task of D user


Crontab restrictions: the same as the atd service


/Etc/cron. allow -- write a common user name that allows crontab to be used, and write one row. If there are some files, do not consider/etc/cron. deny.
/Etc/cron. deny -- write a common user name that rejects crontab use, and write one row. If/cron. allow does not exist, the command takes effect.
 



-- Note the following when using an application:
If there are many time tasks, they are executed cyclically. Based on the task requirements, loads, and time requirements, it is best to evenly split all tasks to prevent tasks from being crowded together at different time points, the server load is too high at a certain time point.




-----------------------------------------------

Anacron features:
Works with the crond service to ensure that the execution of tasks not executed by crond can be delayed.

Configuration File: Vim/etc/anacrontab

Shell =/bin/sh
Path =/sbin:/bin:/usr/sbin:/usr/bin
Mailto = root

Days delayed (minutes) custom name execution command string directory

1 65 cron. daily run-parts/etc/cron. daily
7 70 cron. Weekly run-parts/etc/cron. Weekly
30 75 cron. Monthly run-parts/etc/cron. Monthly


Working principle: Compares the system time with the time mark to determine whether the crond service has been completed.

[Root @ Li ~] # Cat/var/spool/anacron/cron. daily
20100425 -- this is a time mark. The anocron service compares the time mark with your system time. If the time is not today, but yesterday, this indicates that the crond service has not been completed and will be postponed.

[Root @ Li ~] # Cat/var/spool/anacron/cron. Monthly
20100327
[Root @ Li ~] # Cat/var/spool/anacron/cron. Weekly
20100421

Generally, you do not need to adjust the delay.
Custom name

-- This service is generally not called. To ensure the integrity of the crond service, open it.

Chkconfig anacron on












-- $$44


NFS service
Network File System

It was proposed by Sun to share files between networks. It is a shared cluster file system.


[Root @ station218 ~] # Mount 10.1.1.35:/share/soft/mnt
Mount: Mount to NFS server '10. 1.1.35' failed: RPC error: program not registered. -- check that RPC reports an error. Generally, Portmap restarts and registers.


RPC Remote produrce call


[Root @ Li ~] # Netstat-ntlup
Active Internet connections (only servers)
PROTO Recv-Q send-Q local address foreign address State PID/program name
TCP 0 0 0.0.0.0: 2049 0.0.0.0: * listen-
TCP 0 0 0.0.0.0: 770 0.0.0.0: * Listen 6527/rpc. mountd
TCP 0 0 0.0.0.0: 49935 0.0.0.0: * listen-
TCP 0 0 0.0.0.0: 111 0.0.0.0: * Listen 6447/Portmap
TCP 0 0 0.0.0.0: 756 0.0.0.0: * Listen 6512/rpc. rquotad
TCP 0 0: 80: * Listen 2130/httpd
TCP 0 0: 22: * Listen 2027/sshd
UDP 0 0 0.0.0.0: 2049 0.0.0.0 :*-
UDP 0 0 0.0.0.0: 47852 0.0.0.0 :*-
UDP 0 0 0.0.0.0: 111 0.0.0.0: * 6447/Portmap
UDP 0 0 0.0.0.0: 753 0.0.0.0: * 6512/rpc. rquotad
UDP 0 0 0.0.0.0: 767 0.0.0.0: * 6527/rpc. mountd




Portmap 111 port function port Registration
NFS port 2049
Other ports started by rpc. xxx must be registered with port 111.


Create an NFS server

[Root @ Li ~] #/Etc/init. d/Portmap start
[Root @ Li ~] #/Etc/init. d/nfs start -- start these two services


Configuration file:
Vim/etc/exports

Parameters:
RO read-only
RW readable and writable
Root_squash indicates that the client is mounted to the nfsnobody user. By default, no data is written.
No_root_squash indicates that the client is mounted as the root user.
Sync Synchronization
Async asynchronous



/Share/ISO * (RO) -- share/ISO to * (representing all IP addresses) RO (representing read-only)

/Share/ISO * (RW) -- RW indicates readable and writable

/Share/ISO 10.1.1.0/24 (RO) -- only share the IP address with the computer of 10.1.1.
/Share/ISO 10.1.1.0/255.255.255.0 (RO)

/Share/ISO 10.1.1.218/255.255.255.255 (RO) -- defines that only 10.1.1.218 can be accessed by this computer.
/Share/ISO 10.1.1.218/32 (RO)

/Share/ISO 10.1.1.218/32 (RO) 10.1.1.254/32 (RO) -- defines that only 218 and 254 can be accessed.


About NFS permissions:
The client Mount directory permission is shared by the server.


The default permission for the NFS service shared directory must be mounted by the nfsnobody user.
There is such a sentence in/etc/passwd.
Nfsnobody: X: 65534: 65534: anonymous NFS User:/var/lib/nfs:/sbin/nologin



/Share/ISO * (RO) equals/share/ISO * (RO, root_squash) by default)
-- Root_squash indicates that the client is mounted as an nfsnobody user.


/Share/ISO 10.1.1.218/32 (RO, no_root_squash) 10.1.1.254/32 (RO, root_squash)
-- No_root_squash indicates that the client is mounted as a root user. Even if 218 has W permission on/share/ISO, it cannot be written because the RO parameter is determined to be read-only.



/Share/ISO 10.1.1.218/32 (RW, anonuid = 533, anongid = 534) -- specify the client to be mounted as uid = 533, gid = 534




-- After modifying/etc/exports, restart the service to make it take effect.


You do not need to restart the service to make the modified configuration file take effect.

Exportfs-ARV -- re-read the shares in the/etc/exports file and import
-AUV -- unmount the sharing in the/etc/exports file, which is invisible to others showmount-E and cannot be mounted.

[Root @ Li ISO] # Cat/var/lib/nfs/etab
/Share/install * (RO, sync, wdelay, hide, nocrossmnt, secure, root_squash, no_all_squash, no_subtree_check, Token, ACL, mapping = identity, anonuid = 65534, anongid = 65534)
/Share/soft * (RO, sync, wdelay, hide, nocrossmnt, secure, root_squash, no_all_squash, no_subtree_check, Token, ACL, mapping = identity, anonuid = 65534, anongid = 65534)
/Share/ISO * (RO, sync, wdelay, hide, nocrossmnt, secure, root_squash, no_all_squash, no_subtree_check, Token, ACL, mapping = identity, anonuid = 65534, anongid = 65534)


CAT/var/lib/nfs/xtab



-- Client operations
Showmount-e 10.1.1.35

Mount 10.1.1.35:/share/ISO/mnt






---------------------------------------------------------------------------------


Mount problems:

1. The client mounts the shared directory of the server, but there is no umount. However, if the server is shut down first, the client may fail to shut down normally, or umount may fail to mount the shared directory.

2. Mount 10.1.1.35:/share/ISO // mnt
Method 1: Vim/etc/fstab
10.1.1.35:/share/ISO/mnt NFS ults 0 0

Run the Mount-a command to verify that/mnt is assigned to umount before verification.

Method 2:
Vim/etc/rc. Local
Mount 10.1.1.35:/share/ISO // mnt


Method 3:
Automatic mounting using autofs

/Etc/init. d/autofs -- service script to ensure that the service is started

/Etc/auto. Master -- master configuration file

Vim/etc/auto. Master
/Nfs/etc/auto. NFS -- write this configuration to indicate that the mount option under the/NFS directory is set by/etc/auto. the/NFS Directory determined by the NFS configuration file and/etc/auto. NFS files do not exist. You can customize them.

Mkdir/nfs



Vim/etc/auto. NFS
Iso-10.1.1.35:/share/ISO
Soft-10.1.1.35:/share/soft
Install-10.1.1.35:/share/install
-- These three statements indicate that the three shared directories on 10.1.1.35 are automatically mounted to the/nfs/ISO,/nfs/soft,/nfs/install directories, in the middle, "-" indicates the Mounting Parameter. Here, "-" indicates the default mounting parameter.



-- The mounted directory cannot be seen by default by using the LS command under the/NFS directory, but can be included in CD/nfs/ISO. This will automatically mount the directory for you.
In about five minutes, if it is not used, it will automatically umount out.







--------------------------------------------------------------------------


Question:

1. Package and use bz2 to compress the backup/var/log directory to the/tmp directory every day. Use crontab for the backup and ensure its integrity.

2. Configure the NFS service

Share your/share/soft directory and require the client to be mounted as a root user
/Share/source directory. The client must be mounted as uid = 600 and gid = 700.
Use the autofs service for automatic mounting






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.