开发者

Cronjob or rake task for automate a download, unzip and move to a specified directory

I'm not sure if this should be achieved using cron job or rake task.

There is this large zipped file (250MB+) that is provided by third-party, that is updated weekly. I can't be downloading it to my local machine and uploading to the server weekly to replace the old data. Is there anyway I can write such workflow:

  1. Download a zipped file from this URL: http://download.abc.com/data.zip every Sunday 4am.
  2. Unzip it to data.
  3. Move the folder, its subfolders and contents to public/data and replace old public/data.
开发者_开发技巧

Many thanks.


This sounds like a bash script. Install it with crontab -e.

#!/bin/bash
cd /tmp
mkdir data
cd data
wget http://download.abc.com/data.zip
unzip data.zip
rm -rf /public/data/*
mv data/* /public/data/
chown -R www-data:www-data /public/data/

Didn't test it, but it should do that, what you want. Don't forget to adapt owner/group www-data:www-data to your own needs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜