LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1277|回复: 5

请问一个crontab的问题!

[复制链接]
发表于 2003-1-28 14:48:24 | 显示全部楼层 |阅读模式
*/5 * * * * ls >> text.txt 

用这条语句可以每隔5分钟自动运行一次,可是使用 */1 * * * * ls >> text.txt 却不会运行,改成2或10也不行,请问是什么原因?
发表于 2003-1-28 17:00:13 | 显示全部楼层
??? sorry ...
我认为用循环结构,也许~~~好些;) 试试用sleep命令,再放在后台运行,
#! /bin/bash
while
sleep 5
do
ls > 1.txt
done
$sh test &
这样似乎也起到你说的作用呀
发表于 2003-1-28 17:01:58 | 显示全部楼层
sleep xxxx //设定睡眠时间(秒)
我对crontab不是很精通,
 楼主| 发表于 2003-1-28 17:03:43 | 显示全部楼层
没错,用sleep应该也可以达到这样的效果,可是我想知道的是为什么*/5可以5分钟运行一次,而*/10不是10分钟运行一次,*/n,这个n到底是代表什么?
发表于 2003-1-28 17:36:41 | 显示全部楼层
It should work. I have tested it.

Probably you have to wait 5 minutes after you change the crontab. Then the crontab is active.

# the following example works well
*/2 7-19 * * 1-5 date >>$HOME/t2.txt
*/1 7-19 * * 1-5 date >>$HOME/t1.txt
 楼主| 发表于 2003-1-29 09:41:05 | 显示全部楼层
现在可以了,谢谢两位的帮助!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表