- 论坛徽章:
- 0
|
本帖最后由 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 |
|