Upload
mimis
View
121
Download
0
Embed Size (px)
DESCRIPTION
第 21 章 调度与网络. 内容概要. ◆ 使用 crontab 文件周期性调度任务的运行 ◆ 使用 at 命令调度一个或一系列任务在将来的某一时刻运行 ◆ 使用 batch 命令将任务调度到一个队列中,减少系统的瞬时负载。. 内容概要. ◆ 了解基本的网络术语 ◆ 为以太网和令牌环网配置 TCP/IP ◆ 使用一些标准的 TCP/IP 工具 ◆ 登录到其他系统 ◆ 传输文件 ◆ 运行命令. cron daemon. ◆ 负责运行被调度的任务 ◆ crontab 命令的事件 (有规律的调度任务) - PowerPoint PPT Presentation
Citation preview
23/4/21 Dalian University of Technology 1
第第 2121 章 调度与网络章 调度与网络
23/4/21 Dalian University of Technology 2
内容概要内容概要
◆ 使用 crontab 文件周期性调度任务的运行
◆ 使用 at 命令调度一个或一系列任务在将来的某一时刻运行
◆ 使用 batch 命令将任务调度到一个队列中,减少系统的瞬时负载。
23/4/21 Dalian University of Technology 3
内容概要内容概要
◆了解基本的网络术语
◆为以太网和令牌环网配置 TCP/IP
◆使用一些标准的 TCP/IP 工具
◆登录到其他系统
◆传输文件
◆运行命令
23/4/21 Dalian University of Technology 4
cron daemoncron daemon
◆负责运行被调度的任务
◆ crontab 命令的事件 (有规律的调度任务)
◆ at 命令的事件 (只在指定时刻执行一次)
◆ batch 命令的事件 (在 CPU 的负载低的时候运行)
23/4/21 Dalian University of Technology 5
crontabcrontab 文件文件
◆用于启动规律性的任务
◆调度的内容在下面的文件中定义:
/var/spool/cron/crontabs/ $USER
◆控制哪些用户可以使用 crontab 的权限文件: /var/adm/cron/cron.deny 不能使用 crontab 的用户
/var/adm/cron/cron.allow 出能够使用 crontab 的用户
◆缺省情况下存在一个空的 cron.deny
◆ cron.deny 比 cron.allow 优先级高
23/4/21 Dalian University of Technology 6
系统日期和时间系统日期和时间
$ crontab -l
#0 3 * * * /usr/sbin/skulker#45 2 * * 0 /usr/lib/spell/compress…0 11 * * * /usr/bin/errclear -d S,O 300 12 * * * /usr/bin/errclear -d H 900 15 * * * /usr/lib/ras/dumpcheck >/dev/null 2>&1
$ crontab -l
#0 3 * * * /usr/sbin/skulker#45 2 * * 0 /usr/lib/spell/compress…0 11 * * * /usr/bin/errclear -d S,O 300 12 * * * /usr/bin/errclear -d H 900 15 * * * /usr/lib/ras/dumpcheck >/dev/null 2>&1
◆ crontab 文件的格式
分 时 日 月 周 命令
23/4/21 Dalian University of Technology 7
编辑编辑 crontabcrontab
◆ 编辑 crontab 文件
# crontab -e# crontab -e
◆ 比较安全的方式
# crontab -l > /tmp/crontmp # vi /tmp/crontmp # crontab /tmp/crontmp
# crontab -l > /tmp/crontmp # vi /tmp/crontmp # crontab /tmp/crontmp
23/4/21 Dalian University of Technology 8
atat 和和 batchbatch 命令命令
at 命令向 cron 提交只需执行一次的任务
# at now +2 mins banner hello > /dev/pts/0 <ctrl-d> job user.time.a will be run at date
# at now +2 mins banner hello > /dev/pts/0 <ctrl-d> job user.time.a will be run at date
23/4/21 Dalian University of Technology 9
控制控制 atat 提交的任务提交的任务
◆列出 at 任务 at -I [ user ] atq [ user ]
# at –lroot.1118077769.a Mon Jun 6 10:09:29 2007root.1118078393.a Mon Jun 6 10:19:53 2007test2.1118079063.a Mon Jun 6 10:31:03 2007
# at –lroot.1118077769.a Mon Jun 6 10:09:29 2007root.1118078393.a Mon Jun 6 10:19:53 2007test2.1118079063.a Mon Jun 6 10:31:03 2007
23/4/21 Dalian University of Technology 10
◆取消一个任务◆ at -r job◆ atrm [ job | user ]
# at -r test2.1118079063.a
at file: test2.1118079063.a deleted
# at -r test2.1118079063.a
at file: test2.1118079063.a deleted
控制控制 atat 提交的任务提交的任务
23/4/21 Dalian University of Technology 11
batchbatch 命令命令
batch 命令:当系统负载级别允许时运行作业
# batch banner hello > /dev/pts/0 <ctrl-d>
# batch banner hello > /dev/pts/0 <ctrl-d>
23/4/21 Dalian University of Technology 12
什么是什么是 TCP/IPTCP/IP
◆是 Transmission Control Protocol/Internet Protocol的
缩写,传输控制协议 / 互联网协议
◆可以在不同网络类型的系统之间交换数据
◆在网络互联的系统中实现数据传输的透明化
◆ TCP/IP 是与供货商无关的,是由“ Internet Architecture
Board” ( Internet 构架委员会)负责的。
23/4/21 Dalian University of Technology 13
InternetInternet◆ 一个 tcp/ip 网络也叫一个 internet
◆单独的机器叫主机 (hosts) ,这些主机的大小功能可能不同,但在 TCP/IP 网络上的身份是平等的。
◆把个两或多个物理网段互连起来的主机叫网关 (gateways) 。
A
B
E
F
TokenRing
X.25
C
FDDID
gateway Serial
modem
gateway
gateway
gateway
modem
Ethernet
23/4/21 Dalian University of Technology 14
名称和地址名称和地址
◆在 TCP/IP 网络中的每一个系统都被分配一个名字 例如: sys3◆在连接到另外一个系统的时候只需知道名称就可以了 例如: $telnet sys3◆在连接另外的系统和用户时需要知道系统名称和用户名称 例如: $mail fred@sys3◆每个系统可以有一个或多个 TCP/IP 地址 例如: 10.0.0.3◆如果只知道地址而不知道名称,那么你可以通过地址来使
用 TCP/IP 工具。
23/4/21 Dalian University of Technology 15
TCP/IPTCP/IP 网络工具网络工具
◆ 标准的 TCP/IP 设备 包括 : 邮件 , 文件传递 , 远程登录 , 远程执行 , 和远程打印◆ 一些 AIX 应用使用 TCP/IP:
◆ 网络文件系统 (NFS)
◆ 网络信息服务 (NIS)
◆ 域名系统 (DNS)
◆ 动态主机配置协议 (DHCP)
◆ 网络社区系统 (NCS)
◆ 分布计算环境 (DCE)
◆ X Windows 和 AIXWindows
◆ Tivoli Netview for AIX
Disk storagePrintersProgramsLoginSessions
NetworkManagement
MailNetwork
File Transfer PC
System p
System p
Other Systems
Server Clients
23/4/21 Dalian University of Technology 16
配置配置 TCP/IPTCP/IP 所需的信息所需的信息
◆地址◆分配一个唯一 TCP/IP 地址给一个网络适配器,通常还有一个子网
掩码( Subnet Mask )。这些通常由网络管理员来分配。◆名称
每台机器都有一个唯一主机名( hostname )每台机器必须能访问一个地址与名称之间转换的列表。可以是:
/etc/hosts 文件域名服务器( DNS ),此种情况必须知道域名和域名的地址。
◆路由( route )系统为了实现与其他网络上系统的通讯,必须能够找到通讯所需网
关( gateway )。
23/4/21 Dalian University of Technology 17
配置配置 TCP/IPTCP/IP
Minimum Configuration & StartupTo Delete existing configuration data, please use Further Configuration menusType or select values in entry fields.Press Enter AFTER making all desired changes [Entry Fields]* HOSTNAME [sys1]* Internet ADDRESS (dotted decimal) [10.0.0.1] Network MASK (dotted decimal) [255.255.255.0]* Network INTERFACE en0 NAMESERVER Internet ADDRESS (dotted decimal) [] DOMAIN Name [] Default Gateway Address (dotted decimal or symbolic name) [10.0.0.192] Cost [0] # Do Active Dead Gateway Detection? no + Your CABLE Type N/A +START TCP/IP daemons Now no + F1=Help F2=Refresh F3=Cancel F4=List Esc+5=Reset Esc+6=Command Esc+7=Edit Esc+8=Image Esc+9=Shell Esc+0=Exit Enter=Do
Minimum Configuration & StartupTo Delete existing configuration data, please use Further Configuration menusType or select values in entry fields.Press Enter AFTER making all desired changes [Entry Fields]* HOSTNAME [sys1]* Internet ADDRESS (dotted decimal) [10.0.0.1] Network MASK (dotted decimal) [255.255.255.0]* Network INTERFACE en0 NAMESERVER Internet ADDRESS (dotted decimal) [] DOMAIN Name [] Default Gateway Address (dotted decimal or symbolic name) [10.0.0.192] Cost [0] # Do Active Dead Gateway Detection? no + Your CABLE Type N/A +START TCP/IP daemons Now no + F1=Help F2=Refresh F3=Cancel F4=List Esc+5=Reset Esc+6=Command Esc+7=Edit Esc+8=Image Esc+9=Shell Esc+0=Exit Enter=Do
# smit mktcpip
23/4/21 Dalian University of Technology 18
FlatFlat 名称解析名称解析
# more /etc/hosts
# The format of this file is:# Internet Address Hostname # Comments# Items are separated by any number of blanks and/or tabs. A '#'# indicates the beginning of a comment; characters up to the end # of the line are not interpreted by routines which search this# file. Blank lines are allowed.
#Internet Address Hostname #Comments127.0.0.1 loopback localhost10.0.0.1 sys1 timeserver10.0.0.2 sys210.0.0.3 sys310.0.0.4 sys4
# more /etc/hosts
# The format of this file is:# Internet Address Hostname # Comments# Items are separated by any number of blanks and/or tabs. A '#'# indicates the beginning of a comment; characters up to the end # of the line are not interpreted by routines which search this# file. Blank lines are allowed.
#Internet Address Hostname #Comments127.0.0.1 loopback localhost10.0.0.1 sys1 timeserver10.0.0.2 sys210.0.0.3 sys310.0.0.4 sys4
23/4/21 Dalian University of Technology 19
标识主机名称标识主机名称
# host sys3sys3 is 10.0.0.3, Aliases: sys3.washington.ibm.com
# host 10.0.0.3sys3 is 10.0.0.3, Aliases: sys3.washington.ibm.com
# host sys3sys3 is 10.0.0.3, Aliases: sys3.washington.ibm.com
# host 10.0.0.3sys3 is 10.0.0.3, Aliases: sys3.washington.ibm.com
# hostnamesys3
# hostnamesys3
◆ host 命令
◆ hostname 命令
23/4/21 Dalian University of Technology 20
TCP/IPTCP/IP 中的基本功能中的基本功能
下面的命令可以在 TCP/IP 环境中使用:◆测试网络连接 ping◆文件传输 ftp◆远程登录 telnet
23/4/21 Dalian University of Technology 21
PingPing 命令命令
◆ ping 192.168.12.251
PING 192.168.12.251:( 192.168.12.251): 56data bytes64bytes from 192.168.12.251: icmp—seq=0 ttl=255 time=0ms64bytes from 192.168.12.251: icmp—seq=1 ttl=255 time=0ms64bytes from 192.168.12.251: icmp-seq=2 ttl=255 time=0ms…3packets transmitted,3packets received,0%packets lossRound-trip min/avg/max=0/0/0ms
PING 192.168.12.251:( 192.168.12.251): 56data bytes64bytes from 192.168.12.251: icmp—seq=0 ttl=255 time=0ms64bytes from 192.168.12.251: icmp—seq=1 ttl=255 time=0ms64bytes from 192.168.12.251: icmp-seq=2 ttl=255 time=0ms…3packets transmitted,3packets received,0%packets lossRound-trip min/avg/max=0/0/0ms
23/4/21 Dalian University of Technology 22
课堂练习课堂练习
1.判断 at.allow 和 at.deny 文件必须都要做设置以控制用户对 at 的使用。
2. 使用 cron ,怎样指定任务在每周四的每小时的 10 分和30 分时执行?
______________________________________3.怎样设置 myscript脚本从现在开始的 10 分钟后执行?______________________________________
23/4/21 Dalian University of Technology 23
课堂练习课堂练习
4. 这些命令可以实现什么功能?◆ ftp : _________________________________
◆ telnet:________________________________
5. 主机和网关有什么区别? ____________________________________
6. 判断 TCP/IP 网络中的每台主机都有唯一的主机名称和TCP/IP 地址。
7. 在 Flat 网络中哪个文件保存了主机名称与 ip 地址之间的解析关系? _____________________________
23/4/21 Dalian University of Technology 24
课堂练习答案课堂练习答案
1. 错误,只需要设置两个文件中的一个就可以了
2. 10,30 * * * 4 <job>
3. #at now +10 minutes myscript <ctrl-d>
23/4/21 Dalian University of Technology 25
课堂练习答案课堂练习答案
4. ftp 文件传输 telnet 远程登录5. 主机是独立的链接到网络的机器; 网关是特殊类型的主机,把两个或更多的物理网络 连接在一起6. hostname , ifconfig7. /etc/hosts