I want to create a script that checks an URL and perform an action (download + unzip) when the “Last-Modified” header of the remote file changed. I thought about fetching the header with curl but then I have to store it somewhere for each file and perform a date comparison.
Does anyone have a different idea using (mostly) standard unix tools?
thanks
A possible solution would be periodically running this algorithm on the client box.
If-Modified-Sinceheader equal to the date of your local file. If the file does not exist yet do not include this header;If-Modified-Sinceheader in the payload or send304 Not ModifiedHTTP status.200 OKHTTP status simply get the payload from the HTTP body and unzip the file.304 Not Modifiedyou know that your file is up-to-date.Last-Modifiedheader to touch your local file. This way you will be in sync with the server datetime.Another way would be for the server to push notifications (a broadcast package for example) when the file is changed. When the notification is received the client would then execute the above algorithm. This would imply code to live in the HTTP server that listens for file system changes and then broadcast them to interested parties.
Perhaps this info for the
curlcommand is of some importance:To sum up, you will need: