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

tonyevehello 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
...全文
254 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
crontab可以让你定时执行
dennis_duan 2007-02-27
  • 打赏
  • 举报
回复
把你的命令写到一个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分钟该脚本就会自动执行一次。

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧