LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: zonzi

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

[复制链接]
 楼主| 发表于 2004-4-3 22:30:45 | 显示全部楼层
at命令不能执行!!!!!!
bash-2.05b# whereis at
at:
???????
怎么这么怪,at应该是bash里的吧,....
发表于 2004-4-3 22:47:47 | 显示全部楼层
最初由 zonzi 发表
at命令不能执行!!!!!!
bash-2.05b# whereis at
at:
???????
怎么这么怪,at应该是bash里的吧,....

真是很怪~,我用的是redhat,
发表于 2004-4-3 22:50:53 | 显示全部楼层
兄弟不如到slackware版区问问一些系统特有的细节。在下用过lfs,但也没有出现过这类情况。:sorry
 楼主| 发表于 2004-4-3 22:57:08 | 显示全部楼层
也是,多谢两位大哥!!!!!
 楼主| 发表于 2004-4-4 18:59:10 | 显示全部楼层
现在at能用了,原来at不是在bash里的,是个软件,
但crontab死活不肯运行.....
发表于 2004-4-4 19:07:47 | 显示全部楼层
执行crontab -e,是不是进入编辑状态? 如果是,那么
ls /var/spool/cron
看有 没有你这个用户的文件
看我的:
/etc:cd /var/spool/cron
/var/spool/cron:ls
javalee  tmp.562  tmp.835  tmp.886
/var/spool/cron:whereis crontab
crontab: /usr/bin/crontab /etc/crontab /usr/share/man/man5/crontab.5.gz /usr/share/man/man1/crontab.1.gz
/var/spool/cron:ls /var/spool/cron/javalee
/var/spool/cron/javalee   #这个文件就是crontab -e后生成的文件
/var/spool/cron:cat /var/spool/cron/javalee
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.895 installed on Sat Apr  3 21:12:31 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
#* * * * * javalee /home/javalee/myshell/hello
/var/spool/cron:
当然前提是要启动cornd后台服务.goodluck... ;)
发表于 2004-4-4 20:03:54 | 显示全部楼层
(ls /home/zhong/soft/>>/home/zhong/haha)

加上括号,
或者把一组命令写到一个脚本时
在cron中调用这个脚本

cron比较偏好单独的命令哦
 楼主| 发表于 2004-4-4 20:11:35 | 显示全部楼层
有这个文件:
bash-2.05b# pwd
/var/spool/cron/crontabs
bash-2.05b# ls
root  zhong
bash-2.05b# more zhong
5, 15, 25, 35, 45, 55 * * * * ls /home/zhong/soft/>>/home/zhong/haha

:confused::confused::confused:
真是哭校不得的问题.....
bash-2.05b# more root
# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null.  We'll do this here since these jobs should run
# properly on a newly installed system, but if they don't the average newbie
# might get quite perplexed about getting strange mail every 5 minutes. :^)
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this.  If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null
5, 15, 25, 35, 45, 55 * * * * ls /home/zhong/soft/>>/home/zhong/haha
发表于 2004-4-4 20:16:27 | 显示全部楼层
5, 15, 25, 35, 45, 55 * * * * (ls /home/zhong/soft/>>/home/zhong/haha)
 楼主| 发表于 2004-4-4 20:24:31 | 显示全部楼层
bash-2.05b$ date
日  4月  4 14:25:22 CEST 2004
bash-2.05b$ more haha

bash-2.05b$ crontab -l
5, 15, 25, 35, 45, 55 * * * * (ls /home/zhong/soft/>>/home/zhong/haha)

。。。。。。。。。。。。。。。。。。。。!!!!!!!!

567 ?        S      0:00 /usr/sbin/crond -l10
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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