求助:10.10版本 /etc/crontab定时放音乐 出错了 高手请进!!!
发表于 : 2010-10-14 12:05
想法是 定时打开一个音乐播放列表,实现早上定时闹钟定时关机的功能
sudo gedit /etc/crontab修改如下:
6 8 * * * root gnome-mplayer --display=0>>/tmp/tmp1.txt
35 8 * * * root halt
7 8 * * * root /home/xcz/start.sh>>/tmp/tmp2.txt
8 8 * * * root totem>>/tmp/tmp3.txt
37 8 * * * root poweroff
用sudo restart cron重起服务
start.sh脚本 权限777或755都设过 内容如下:
#!/bin/bash
gnome-mplayer /home/xcz/xcz.pls
(xcz.pls为音乐播放列表)
在终端中打开可正常播放 (在10.04版本中可定时开启的)
结果:两个关机命令都是有效的
tmp1.txt显示:
无法打开显示:0
运行'gnome-mplayer --help'查看完整的可用命令参数。
tmp2.txt显示:
无法打开显示:
运行'gnome-mplayer --help'查看完整的可用命令参数。
tmp3.txt显示:
无法打开显示:
请运行 “totem --help”查看完整的命令行选项列表。
有人说:gui的程序也需要加上 export DISPLAY=:0 才能显示gui的界面
8 8 * * * root export DISPLAY=:0 && totem>>/tmp/tmp3.txt
结果一样:
还有人说:环境/路径 不同 加source ~/.bash_profile
结果:./start.sh: line 1: /home/xcz/.bash_profile: 没有那个文件或目录
或 ./start.sh: line 2: /home/xcz/.bash_profile: 没有那个文件或目录
sudo gedit /etc/crontab修改如下:
6 8 * * * root gnome-mplayer --display=0>>/tmp/tmp1.txt
35 8 * * * root halt
7 8 * * * root /home/xcz/start.sh>>/tmp/tmp2.txt
8 8 * * * root totem>>/tmp/tmp3.txt
37 8 * * * root poweroff
用sudo restart cron重起服务
start.sh脚本 权限777或755都设过 内容如下:
#!/bin/bash
gnome-mplayer /home/xcz/xcz.pls
(xcz.pls为音乐播放列表)
在终端中打开可正常播放 (在10.04版本中可定时开启的)
结果:两个关机命令都是有效的
tmp1.txt显示:
无法打开显示:0
运行'gnome-mplayer --help'查看完整的可用命令参数。
tmp2.txt显示:
无法打开显示:
运行'gnome-mplayer --help'查看完整的可用命令参数。
tmp3.txt显示:
无法打开显示:
请运行 “totem --help”查看完整的命令行选项列表。
有人说:gui的程序也需要加上 export DISPLAY=:0 才能显示gui的界面
8 8 * * * root export DISPLAY=:0 && totem>>/tmp/tmp3.txt
结果一样:
还有人说:环境/路径 不同 加source ~/.bash_profile
结果:./start.sh: line 1: /home/xcz/.bash_profile: 没有那个文件或目录
或 ./start.sh: line 2: /home/xcz/.bash_profile: 没有那个文件或目录