您的位置:程序门 -> linux/unix社区 -> 系统维护与使用区



[求助]linux下如何在shell script中实现在某特殊时间点,批量执行脚本指令?(在线等回复)


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


[求助]linux下如何在shell script中实现在某特殊时间点,批量执行脚本指令?(在线等回复)
发表于:2007-02-27 12:07:47 楼主
#程序需求:实现以下信息的记录
#程序要求:在特定时间同时执行以下记录操作,信息统一记录在(xx文件夹),可同时记录x小时信息记录。
   
    sar   -u   2   30   > >   total_info.txt  
    iostat   -t   -c   2   30   > >   cpu_info.txt
    vmstat   -s   k   2   30   > >   memory_info.txt
    iostat   -d   2   30   > >   decive_io_info.txt
发表于:2007-02-27 12:38:361楼 得分:0
crontab可以让你定时执行
发表于:2007-02-27 15:46:022楼 得分:0
把你的命令写到一个shell脚本中:

#!/bin/sh

sar   -u   2   30   > >   total_info.txt  
iostat   -t   -c   2   30   > >   cpu_info.txt
vmstat   -s   k   2   30   > >   memory_info.txt
iostat   -d   2   30   > >   decive_io_info.txt

假设shell脚本名称为monitorall.sh

修改你的crontab,增加一行:

5   *   *   *   *   /home/yourhome/monitorall.sh

这样每5分钟该脚本就会自动执行一次。


快速检索

最新资讯
热门点击