LinuxSir.cn,穿越时空的Linuxsir!

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

请问怎么写个定时运行某命令的脚本?

[复制链接]
发表于 2004-4-3 06:34:05 | 显示全部楼层 |阅读模式
比如每三个小时运行一次reboot
发表于 2004-4-3 07:28:40 | 显示全部楼层
cron就能做,不用写什么脚本吧。
 楼主| 发表于 2004-4-3 07:41:11 | 显示全部楼层
bash-2.05b$ cron
bash: cron: command not found
请问怎么用法?
多谢
发表于 2004-4-3 10:20:40 | 显示全部楼层
$ man crontab
$ man crond
发表于 2004-4-3 11:30:07 | 显示全部楼层

回复: 请问怎么写个定时运行某命令的脚本?

最初由 zonzi 发表
比如每三个小时运行一次reboot
crontab的常用用法见:
http://www.linuxsir.cn/forum.php?mod=viewthread&tid=5115
 楼主| 发表于 2004-4-3 18:30:09 | 显示全部楼层
我做的clontab:
bash-2.05b$ crontab -l
5, 15, 25, 35, 45, 55 * * * * /bin/echo /usr/bin/ls /home/zhong/soft/>/home/zhong/haha
但不能用....
哪位再能帮帮我啊.....
多谢各位大哥
发表于 2004-4-3 19:47:54 | 显示全部楼层
最初由 zonzi 发表
我做的clontab:
bash-2.05b$ crontab -l
5, 15, 25, 35, 45, 55 * * * * /bin/echo /usr/bin/ls /home/zhong/soft/>/home/zhong/haha
但不能用....
哪位再能帮帮我啊.....
多谢各位大哥

你写的是什么? :ask
 楼主| 发表于 2004-4-3 19:54:49 | 显示全部楼层
就是每个小时的5min,15min,25min,..55min 都做一次
echo ls /home/zhong/soft >(存到) 文件haha在/home/zhong下
但这个存档文件从来没有出来....
最主要的是这个存档文件从来没有出来
发表于 2004-4-3 19:58:51 | 显示全部楼层
ls /home/zhong/soft >>/home/zhong/haha
 楼主| 发表于 2004-4-3 20:08:09 | 显示全部楼层
5, 15, 25, 35, 45, 55 * * * * ls /home/zhong/soft/>>/home/zhong/haha
bash-2.05b$ pwd
/home/zhong
bash-2.05b$ more haha

bash-2.05b$
好像还有问题,我手动创建了haha 文件在/home/zhong下但到05分以后,haha文件还是空的.....
在/home/zhong/soft下:
bash-2.05b$ pwd
/home/zhong/soft
bash-2.05b$ ls
ABC-Linux-V.2.4.3
ABC-Linux-V.2.4.3-alpha.tar.gz
bttv-0.9.12.tar.gz
CodeWeavers.CrossOver.Office.v2.1.for.Linux-BEAN
DCompiler.jar
enqq2003_0925.exe
file_id.diz
mult
nettv.exe
Perl编程24学时教程.tar.gz
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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