Cron 不会运行我的脚本
我无法让 cron 运行我的脚本,我已经没有主意了。 我在这台机器上运行 Ubuntu 10.04。 该脚本可以从命令行运行,没有任何问题。其他测试脚本工作 并且设置与 timelapvid 相同。
这是我的 crontab -e,其中 bench 是用户名:
00 00 * * * /home/bin/bench/timelapvid >> /home/bin/timelapvid.log
在 Ubuntu 中,〜/bin 目录在登录时添加到 PATH 变量中,以避免修改 /bin。
timelapvid的内容:
## timelapse is a dir which contains the still pics
cd ~/bin/timelapse || exit
## only work on new pics, remove the colon, dvd-slideshow doesn't like it
ls -1 | grep : > list
for i in `cat list`
do
mv $i `echo $i | sed 's/:/./g'`
done
#build the slide show list and change the time for each slide
dir2slideshow -n "Time Lapse Video" . && sed -i 's/:5/:0.5/g' "Time Lapse Video.txt"
# remove the last three lines of the above .txt
lines=$(wc -l < "Time Lapse Video.txt")
target=$((lines-2))
sed -i "$target,$lines d" "Time Lapse Video.txt"
# make the time on the last slide longer
lines=$(wc -l < "Time Lapse Video.txt")
sed -i ""$lines"s/:0.5/:3/" "Time Lapse Video.txt"
dvd-slideshow -f "Time Lapse Video.txt" && mv "Time Lapse Video.vob" ../video /TimeLapseVideo.vob
rm list
### Update Web Page
rsync -r --delete ~/bin/video/ user@sever:public_html/circuits/timelap/video/
echo -e "\n****UPDATE SUCCESSFUL****\n"
谢谢, 工作组
I can't get cron to run my script and I'm out of ideas.
I'm running Ubuntu 10.04 on this machine.
The script works from the command line with no problems. Other test scripts work
and are set up the same as timelapvid.
here's my crontab -e, where bench is the user name:
00 00 * * * /home/bin/bench/timelapvid >> /home/bin/timelapvid.log
In Ubuntu the ~/bin directory is added to the PATH variable at login, to avoid modifying /bin.
The contents of timelapvid:
## timelapse is a dir which contains the still pics
cd ~/bin/timelapse || exit
## only work on new pics, remove the colon, dvd-slideshow doesn't like it
ls -1 | grep : > list
for i in `cat list`
do
mv $i `echo $i | sed 's/:/./g'`
done
#build the slide show list and change the time for each slide
dir2slideshow -n "Time Lapse Video" . && sed -i 's/:5/:0.5/g' "Time Lapse Video.txt"
# remove the last three lines of the above .txt
lines=$(wc -l < "Time Lapse Video.txt")
target=$((lines-2))
sed -i "$target,$lines d" "Time Lapse Video.txt"
# make the time on the last slide longer
lines=$(wc -l < "Time Lapse Video.txt")
sed -i ""$lines"s/:0.5/:3/" "Time Lapse Video.txt"
dvd-slideshow -f "Time Lapse Video.txt" && mv "Time Lapse Video.vob" ../video /TimeLapseVideo.vob
rm list
### Update Web Page
rsync -r --delete ~/bin/video/ user@sever:public_html/circuits/timelap/video/
echo -e "\n****UPDATE SUCCESSFUL****\n"
thank you,
wbg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Cron 使用自己的最小环境。所以
~
在你的脚本中没有任何意义。如果您在 crontab 中定义它,则可以使用$HOME
:此外,您确定您的
/home/bin
路径吗?不是类似/home/wbg/bin
吗?Cron uses its own minimal environment. So
~
makes no sense in your script. You could use$HOME
if you define it in your crontab:Besides, are you sure of your
/home/bin
path? Isn't is something like/home/wbg/bin
?