0

Crontab 启动脚本,播客正确更新,但没有文件重命名(第一次循环)或文件移动(第二次循环)。如果我从命令行运行脚本,则可以完美运行。

我添加了“echo”行进行故障排除,通过命令行和 crontab 运行时 $file 变量是一致的。

#/bin/sh

# Mad Money updates at 6:40 pm (timezone?) M-F
# At 6:30 pm CST it was ready to download
# http://podcast.cnbc.com/mmpodcast/lightninground.xml

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
echo "paths"
echo $PATH

podcast_folder=$"/home/zenon/podcasts/MAD_MONEY_W__JIM_CRAMER_-_Full_Episode"
episode_folder=$"/mnt/black-2tb-001/plex-server/shows/Mad-Money/Season-1"

hpodder update
sleep 1

hpodder download
sleep 1

cd ${podcast_folder}

for file in "$podcast_folder"/*.mp4; do
    echo "Processing ${file}"
    #"MadMoney-" Name
    name=${file:60:9}
        echo "podcast name is ${name}"
    #"04" Month
    month=${file:69:2}
        echo "month is ${month}"
    #"18" Day
    day=${file:71:2}
        echo "day is ${day}"
    #"13" yr
    yr=${file:73:2}
        echo "year is 20${yr}"
    title="${name}20${yr}.${month}.${day}.mp4"

        echo "file ${file}"
        echo "title ${title}"

#   cp ${file} ${title}
    mv ${file} ${title}

done

cd ${podcast_folder}


for file in "$podcast_folder"/*.mp4; do
    chown zenon:plex ${file}
    mv ${file} ${episode_folder}
done

# deletes any files older than 9 days
find ${episode_folder} -type f -mtime +9 -exec rm {} \;

exit

这是脚本的调试输出

cat cron.log 
paths
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
1 podcast(s) to consider

Get: 4 MAD MONEY W/ JIM CRAMER - Full Episode                                  
100%                                                                   1 B/s 0s
0 episode(s) to consider from 1 podcast(s)
0%                                                                     0 B/s 0s
Processing $/home/zenon/podcasts/MAD_MONEY_W__JIM_CRAMER_-_Full_Episode/*.mp4
4

1 回答 1

1

你在第一行有错误,你应该改变

#/bin/sh#!/bin/sh

于 2013-05-30T17:45:22.717 回答