免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2931 | 回复: 17
打印 上一主题 下一主题

求助 一个非常奇怪的crontab问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-02-08 15:52 |只看该作者 |倒序浏览
本帖最后由 wazhl 于 2012-02-08 15:56 编辑

写了一个脚本: topinfo.sh

#!/bin/bash
day=`/bin/date +%d`
hh=`/bin/date +%H`
ss=`/bin/date +%M`
/usr/bin/top -d 30 -n 1 > /tmp/topinfo${hh}${ss}.out

直接运行 sh topinfo.sh 的话有输出。

但把它写到crontab里
00,10,20,30,40,50  2,3,4,15  *  *  * /tmp/topinfo.sh

却输出空文件.

-rw-r--r--  1 root    root        0 Feb  8 03:00 topinfo0300.out
-rw-r--r--  1 root    root        0 Feb  8 03:10 topinfo0310.out
-rw-r--r--  1 root    root        0 Feb  8 03:20 topinfo0320.out
-rw-r--r--  1 root    root        0 Feb  8 03:30 topinfo0330.out
-rw-r--r--  1 root    root        0 Feb  8 03:40 topinfo0340.out
-rw-r--r--  1 root    root        0 Feb  8 03:50 topinfo0350.out
-rw-r--r--  1 root    root        0 Feb  8 04:00 topinfo0400.out
-rw-r--r--  1 root    root        0 Feb  8 04:10 topinfo0410.out
-rw-r--r--  1 root    root        0 Feb  8 04:20 topinfo0420.out
-rw-r--r--  1 root    root        0 Feb  8 04:30 topinfo0430.out
-rw-r--r--  1 root    root        0 Feb  8 04:40 topinfo0440.out
-rw-r--r--  1 root    root        0 Feb  8 04:50 topinfo0450.out

论坛徽章:
0
2 [报告]
发表于 2012-02-08 15:58 |只看该作者
操作系统版本:

cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 1

论坛徽章:
0
3 [报告]
发表于 2012-02-08 16:01 |只看该作者
哪位知道呢?在线等哦~~~

论坛徽章:
0
4 [报告]
发表于 2012-02-08 16:18 |只看该作者
top的关系

论坛徽章:
0
5 [报告]
发表于 2012-02-08 16:23 |只看该作者
top 那要怎么写呢?
只是觉得奇怪,我直接运行top这命令,和运行这个脚本,都可以的。

论坛徽章:
0
6 [报告]
发表于 2012-02-08 16:37 |只看该作者
本帖最后由 wazhl 于 2012-02-08 16:38 编辑

期待各位的回复噢。

论坛徽章:
1
2015亚冠之吉达阿赫利
日期:2015-09-09 16:42:38
7 [报告]
发表于 2012-02-08 16:49 |只看该作者
. ~/.bash_profile

day=`/bin/date +%d`
hh=`/bin/date +%H`
ss=`/bin/date +%M`
/usr/bin/top -d 30 -n 1 > /tmp/topinfo${hh}${ss}.out

试试

论坛徽章:
0
8 [报告]
发表于 2012-02-08 17:52 |只看该作者

没有此文件

. ~/.bash_profile


jiaogeshahaone 发表于 2012-02-08 16:49
. ~/.bash_profile

day=`/bin/date +%d`

论坛徽章:
1
2015亚冠之吉达阿赫利
日期:2015-09-09 16:42:38
9 [报告]
发表于 2012-02-08 17:55 |只看该作者
回复 8# wazhl


    . /etc/profile

论坛徽章:
0
10 [报告]
发表于 2012-02-08 18:01 |只看该作者
还是一样哦,没数据

-rw-r--r--  1 root    root        0 Feb  8 18:00 topinfo1800.out


jiaogeshahaone 发表于 2012-02-08 17:55
回复 8# wazhl
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP