我不能让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"谢谢你,wbg
发布于 2011-10-17 20:27:01
Cron使用自己的最小环境。所以~在你的脚本中没有任何意义。如果您在您的crontab中定义了$HOME,则可以使用它:
# environment
HOME=/home/wbg
# tasks
00 00 * * * /home/bin/bench/timelapvid >> /home/bin/timelapvid.log另外,你确定你的/home/bin路径吗?是不是有点像/home/wbg/bin
https://stackoverflow.com/questions/7266860
复制相似问题