2014-10-29 89 views
0

这个shell脚本应该添加一切放在文件夹中传输。有一个文件夹工作正常,但是当我在同一时间添加多个然后一个文件夹时,它会忽略第二个文件夹。inotifywait添加多个文件

while true; 
do 
file=$(inotifywait -e moved_to --format %f /srv/watchfolderfilme) 
file="/srv/watchfolderfilme/$file" 
    transmission-create -o $file.torrent -s 16384 -t http://0.0.0.0:6969/announce $file 
    mv $file /srv/downloads 
    chmod 0777 $file.torrent 
    cp $file.torrent /srv/newtorrentfiles 
    mv $file.torrent /srv/watchfoldertorrents 
done 

回答

0

Rethough我的解决办法,发现一个更好的工作正常多增加

inotifywait -m /srv/watchfolderfilme -e create -e moved_to | 
    while read path action file; do 
# echo "The file '$file' appeared in directory '$path' via '$action'" 
    chmod 0777 $path$file 
    transmission-create -o /srv/newtorrentfiles/$file.torrent -s 16384 -t http://0.0.0.0:6969/announce $path$file 
    mv $path$file /srv/downloads 
    chmod 0777 /srv/newtorrentfiles/$file.torrent 
    cp /srv/newtorrentfiles/$file.torrent /srv/watchfoldertorrents 
done