LinuxSir.cn,穿越时空的Linuxsir!

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

虽然看了论坛大量的crontab问题,但是都没有能解决问题,只好在重新发布一下

[复制链接]
发表于 2004-5-30 12:59:38 | 显示全部楼层 |阅读模式
有一台远程adsl上网机器装(rh9),想知道每天的ip是多少写了一个简单脚本
root#cat mail.sh
    #!/bin/bash
PATH=/sbin:/usr/sbin/bin:/bin:
    ifconfig -a |grep 'ppp0'/tmp/ip.txt
    dt=`date +*%d-%m-%y`
   mail -s ip$dt ****@hotmail.com <ip.txt
    rm -r /tmp/ip.txt
放入cron
   cat /root/root.cron
    00 13 * * * * root /root/mail.sh
crontab -l 可以看到cron
crond已经运行了
runlevel是3
但是crontab就是不执行!!!!有些急了在rh7.2上执行也不行,以前没有问题???
请高手解决一下!!!
发表于 2004-5-30 13:19:10 | 显示全部楼层
使用cron服务需要主意的几点:
1,确保crontab服务正常运行
用service crond status检查一下,用chkconfig atd on启动
2,检查/etc/cron.allow和/etc/cron.deny文件,看是否被禁用
3,root用户所用的配置文件跟普通用户的不一样,他通常在
/etc/crontab而普通用户的是放在/var/spool/cron下
4,确保正确的语法格式
crontab的详细解释,见:
http://www.linuxsir.cn/forum.php?mod=viewthread&tid=5115
 楼主| 发表于 2004-5-30 13:33:10 | 显示全部楼层

这个论坛的编辑功能在那里啊

atd是stop的
现在我已经启动了atd是个什么守护进程????
cron正在测试能不能行!!
发表于 2004-5-30 13:37:45 | 显示全部楼层
sorry,应该是crond这个守护进程 :sorry
 楼主| 发表于 2004-5-30 13:46:52 | 显示全部楼层

crontab还是没有做动作

到底是为什么呢?
发表于 2004-5-30 13:50:58 | 显示全部楼层
我做的实验:
1,生成/var/spool/cron/root
50 13 * * * root >/root/$(date +%F)file
2,启动cornd服务
/root#service crond restart
停止 crond:                                               [  确定  ]
启动 crond:
3, 检查root目录:
/root#ls
anaconda-ks.cfg  install.log  install.log.syslog
4,指定时间后检查root目录:
/root#ls
2004-05-30file  
anaconda-ks.cfg  install.log  install.log.syslog
生效!
 楼主| 发表于 2004-5-30 13:55:24 | 显示全部楼层

再次感谢javelee的热心回复

因为我看过你过去对此问题的解答所以,你的以上步骤我都做过了,在这两台机器上,但是我的cron 没有动作
发表于 2004-5-30 13:59:06 | 显示全部楼层

回复: 再次感谢javelee的热心回复

最初由 xinkeren 发表
因为我看过你过去对此问题的解答所以,你的以上步骤我都做过了,在这两台机器上,但是我的cron 没有动作

没有给你提供什么帮助! :sorry
不果大致的步骤都差不多~,望多看这些命令的手册 :thank
 楼主| 发表于 2004-5-30 14:00:07 | 显示全部楼层

哦对不起后面的动作我没有做!

[root@legend cron]# /sbin/service crond retart
Usage: /etc/init.d/crond {start|stop|status|reload|restart|condrestart}
[root@legend cron]# /sbin/service crond restart
Stopping crond:   OK  ]
Starting crond:   OK  ]
[root@legend cron]# ls
root
[root@legend cron]# cat root
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (mm.cron installed on Sun May 30 13:36:53 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
00 14 * * * *  root /root/mail.sh
[root@legend cron]# cd /root
[root@legend root]# ls
anaconda-ks.cfg  id.txt  ip.txT   mail.sh  mm.txt    rc.fire
Desktop          ip      mac.txt  mm.cron  nat.fire  ss
[root@legend root]#
我的root下为什么只有一个anaconda-ks.cfg文件环境是rh7.2
 楼主| 发表于 2004-5-30 14:01:09 | 显示全部楼层

这是我按你的方法做的有什么错误吗

root@legend cron]# /sbin/service crond retart
Usage: /etc/init.d/crond {start|stop|status|reload|restart|condrestart}
[root@legend cron]# /sbin/service crond restart
Stopping crond: OK ]
Starting crond: OK ]
[root@legend cron]# ls
root
[root@legend cron]# cat root
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (mm.cron installed on Sun May 30 13:36:53 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
00 14 * * * * root /root/mail.sh
[root@legend cron]# cd /root
[root@legend root]# ls
anaconda-ks.cfg id.txt ip.txT mail.sh mm.txt rc.fire
Desktop ip mac.txt mm.cron nat.fire ss
[root@legend root]#
我的root下为什么只有一个anaconda-ks.cfg文件环境是rh7.2
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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