Pages

Monday 11 May 2015

Crontab and wget

I had the following issue - I had to reduce a pretty big xml file to a small file to be downloaded by a mobile app. What I did was pretty simple. In a crontab on my server I set a job for xml compression:

* * * * * root /get.sh >> /tmp/getsh.out 2>&1

In the script:
wget -O /var/www/html/test.xml "http://<domain/ip>/?xml&param=1param&papmm=2param"
bzip2 -c /var/www/html/test.xml > /var/www/html/test.xml.bz2
rm -f /var/www/html/test.xml

So this downloads the xml, bzip shrinks the size and this can be downloaded.