crontab命令没反应-配置正确(已解决)
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
- linux5588
- 帖子: 305
- 注册时间: 2010-07-05 16:10
- 系统: Macos
crontab命令没反应-配置正确(已解决)
设置如下。
第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楼的代码,就可以显示信息了。
第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命令没反应-配置正确
只是执行了date?没指定output的地方,你也看不到啊
重启服务需要root权限,而且是crond,不是cron。arch里面路径应该是/etc/rc.d/crond
重启服务需要root权限,而且是crond,不是cron。arch里面路径应该是/etc/rc.d/crond
- linux5588
- 帖子: 305
- 注册时间: 2010-07-05 16:10
- 系统: Macos
Re: crontab命令没反应-配置正确
不好意思,没写精细
- pityonline
- 帖子: 3864
- 注册时间: 2008-12-09 12:44
- 来自: 北京
- 联系:
Re: crontab命令没反应-配置正确
crontab 配置正确不用手动重启,是即时生效的,有这提示:
显示报时我是这样写的:
-i '/home/pity/icon/gnome-panel-clock.svg'不是必要的,只是显示通知时多个图标,也可以加个声音提示的:
代码: 全选
crontab: installing new crontab
代码: 全选
# 每十分钟报一次时间
*/10 * * * * env DISPLAY=:0.0 notify-send -i '/home/pity/icon/gnome-panel-clock.svg' "`date +\%c`"
代码: 全选
*/10 * * * * env DISPLAY=:0.0 notify-send "`date +\%c`" && aplay /home/pity/snd/check.wav 2>/dev/null
- tenzu
- 论坛版主
- 帖子: 36924
- 注册时间: 2008-11-21 20:26
Re: crontab命令没反应-配置正确
代码: 全选
env DISPLAY=:0.0
- linux5588
- 帖子: 305
- 注册时间: 2010-07-05 16:10
- 系统: Macos
Re: crontab命令没反应-配置正确
怎么用的呀。。我搞来搞去。搞不出来。tenzu 写了:这里,我用 DISPLAY=:0似乎也没问题,至少notify-send和zenity都正常代码: 全选
env DISPLAY=:0.0
*/1 * * * * zenity --progress --title=你好 --width=18 --height=20 --timeout=3
那个命令在终端下是执行的。 放到cron里起不来
第隔一小时提示休息一下
- pityonline
- 帖子: 3864
- 注册时间: 2008-12-09 12:44
- 来自: 北京
- 联系:
Re: crontab命令没反应-配置正确
直接在 crontab 中新建一行,复制这个试试……
代码: 全选
* */1 * * * env DISPLAY=:0.0 notify-send "该休息了!"
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: crontab命令没反应-配置正确
代码: 全选
● 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
- linux5588
- 帖子: 305
- 注册时间: 2010-07-05 16:10
- 系统: Macos
Re: crontab命令没反应-配置正确(已解决)
notify-send "该休息了!"
命令蛮好用的。谢谢各位了。
命令蛮好用的。谢谢各位了。
- qq420100523
- 帖子: 1684
- 注册时间: 2009-07-31 18:56
- 系统: windows、ubuntu
- 来自: 广东阳江
Re: crontab命令没反应-配置正确(已解决)
呃!原来这里就已有人做出了利用crontab提示消息了。。
- mjp123
- 帖子: 702
- 注册时间: 2009-04-09 15:06
Re: crontab命令没反应-配置正确(已解决)
这个有用(最近要按时签到)