「Linux」定时执行下载任务 prewget

#!/bin/bash

if [[ $# != 3 ]]; then
   echo 'usage:prewget $FILE $LINK $TIME '
   echo 'e.g. prewget google google.com 02:11'
   exit 1
fi

# variable
filename=$1
downlink="\"$2\""
downtime=$3
tmpfile="$HOME/Public/prewget_$filename"

# write the code to a script
cat << EOF > $tmpfile
#!/bin/bash
# this is a schedule for download $filename 
wget -c -O $filename $downlink
rm -vf $tmpfile
EOF

# add a new job
at -f $tmpfile $downtime

相关参数:

1. file:下载的路径及文件名;

2. link:下载的链接地址;

3. time:下载时间(合适于校园用户,在晚上下载比较便宜的推荐使用);

posted @ 2012-11-29 16:20  scue  阅读(495)  评论(0编辑  收藏  举报