crontab命令没反应-配置正确(已解决)

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
linux5588
帖子: 305
注册时间: 2010-07-05 16:10
系统: Macos

crontab命令没反应-配置正确(已解决)

#1

帖子 linux5588 » 2010-11-02 20:36

设置如下。
第5模式启动
crontab -e
30 20 * * * /bin/date
ubuntu@ubuntu-desktop:/$ sudo /etc/init.d/cron restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service cron restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the restart(8) utility, e.g. restart cron
cron start/running, process 15073
ubuntu@ubuntu-desktop:/$


测试时老是不动,一点反应也没有。这是怎么回事,
rhel也是这样
arch也是这样
这个到底哪里错了。。。

sudo apt-get install libnotify-bin
再输入7楼的代码,就可以显示信息了。
上次由 linux5588 在 2010-11-03 17:09,总共编辑 3 次。
头像
tenzu
论坛版主
帖子: 36924
注册时间: 2008-11-21 20:26

Re: crontab命令没反应-配置正确

#2

帖子 tenzu » 2010-11-02 20:43

只是执行了date?没指定output的地方,你也看不到啊
重启服务需要root权限,而且是crond,不是cron。arch里面路径应该是/etc/rc.d/crond
头像
linux5588
帖子: 305
注册时间: 2010-07-05 16:10
系统: Macos

Re: crontab命令没反应-配置正确

#3

帖子 linux5588 » 2010-11-02 20:52

不好意思,没写精细
头像
pityonline
帖子: 3864
注册时间: 2008-12-09 12:44
来自: 北京
联系:

Re: crontab命令没反应-配置正确

#4

帖子 pityonline » 2010-11-02 21:59

crontab 配置正确不用手动重启,是即时生效的,有这提示:

代码: 全选

crontab: installing new crontab
显示报时我是这样写的:

代码: 全选

# 每十分钟报一次时间
*/10 * * * * env DISPLAY=:0.0 notify-send -i '/home/pity/icon/gnome-panel-clock.svg' "`date +\%c`"
-i '/home/pity/icon/gnome-panel-clock.svg'不是必要的,只是显示通知时多个图标,也可以加个声音提示的:

代码: 全选

*/10 * * * * env DISPLAY=:0.0 notify-send  "`date +\%c`" && aplay /home/pity/snd/check.wav 2>/dev/null
Pity is the bomp!
活着就是折腾!生命不息,折腾不止!
看这帮家伙在干什么?@pityonline/u
Dropbox+Vps+PC 跑起来了!这是邀请链接
头像
tenzu
论坛版主
帖子: 36924
注册时间: 2008-11-21 20:26

Re: crontab命令没反应-配置正确

#5

帖子 tenzu » 2010-11-02 22:06

代码: 全选

env DISPLAY=:0.0
这里,我用 DISPLAY=:0似乎也没问题,至少notify-send和zenity都正常
头像
linux5588
帖子: 305
注册时间: 2010-07-05 16:10
系统: Macos

Re: crontab命令没反应-配置正确

#6

帖子 linux5588 » 2010-11-02 22:29

tenzu 写了:

代码: 全选

env DISPLAY=:0.0
这里,我用 DISPLAY=:0似乎也没问题,至少notify-send和zenity都正常
怎么用的呀。。我搞来搞去。搞不出来。
*/1 * * * * zenity --progress --title=你好 --width=18 --height=20 --timeout=3
那个命令在终端下是执行的。 放到cron里起不来

第隔一小时提示休息一下
头像
pityonline
帖子: 3864
注册时间: 2008-12-09 12:44
来自: 北京
联系:

Re: crontab命令没反应-配置正确

#7

帖子 pityonline » 2010-11-02 22:33

直接在 crontab 中新建一行,复制这个试试……

代码: 全选

* */1 * * * env DISPLAY=:0.0 notify-send  "该休息了!"
Pity is the bomp!
活着就是折腾!生命不息,折腾不止!
看这帮家伙在干什么?@pityonline/u
Dropbox+Vps+PC 跑起来了!这是邀请链接
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: crontab命令没反应-配置正确

#8

帖子 eexpress » 2010-11-03 9:30

代码: 全选

● cat bin/msg
#!/bin/bash

t="计划任务提醒"
icon="/home/exp/媒体/图标●/spot.jpg"
base_pic_path="/home/exp/媒体/图标●/"
case $# in
1)
        w=$*;;
2)
        t=$1; w=$2;;
3)
        [ -f "$1" ] && icon=$1 || icon="${base_pic_path}/$1"
        t=$2; w=$3;;
*)
        t="格式错误"; w="参数应该介于1-3个。";;
esac
w=`echo $w|ascii2uni -a J`
export DISPLAY=:0.0 && notify-send -i $icon  $t $w
aplay '/home/exp/媒体/事件声音-et/select.wav'  2>/dev/null

代码: 全选

35 08 * * 1,3 msg 开会
● 鸣学
头像
tenzu
论坛版主
帖子: 36924
注册时间: 2008-11-21 20:26

Re: crontab命令没反应-配置正确

#9

帖子 tenzu » 2010-11-03 9:53

拜观神码
头像
linux5588
帖子: 305
注册时间: 2010-07-05 16:10
系统: Macos

Re: crontab命令没反应-配置正确(已解决)

#10

帖子 linux5588 » 2010-11-03 17:10

notify-send "该休息了!"
命令蛮好用的。谢谢各位了。
头像
qq420100523
帖子: 1684
注册时间: 2009-07-31 18:56
系统: windows、ubuntu
来自: 广东阳江

Re: crontab命令没反应-配置正确(已解决)

#11

帖子 qq420100523 » 2011-10-27 0:11

呃!原来这里就已有人做出了利用crontab提示消息了。。 :em20
头像
mjp123
帖子: 702
注册时间: 2009-04-09 15:06

Re: crontab命令没反应-配置正确(已解决)

#12

帖子 mjp123 » 2011-10-27 9:21

这个有用(最近要按时签到)
回复