curl / Mailing Lists / curl-users / Single Mail


Exit code if file is or is not downloaded

From: Gerard Seibert <>
Date: Mon, 15 Apr 2019 16:56:12 +0000

I am using curl as shown here: curl -s -L -R -z "file-name" -O "URL"

What I would like to know is if there is a way to have curl issue an
exit code depending on whether or not it actually downloaded a newer
file. Apparently, curl always exits on "0" unless an error occurs which
means I have to check to see if a newer file was fetched.

The command is being run via a shell script from CRON. Right now I am
comparing the files to see if a newer one was downloaded. It would be
easier if curl simply issued an exit code to indicate that it did or
didn't fetch a newer file.

If this is not currently available in curl, it might be a nice feature
to add to it at some time.




Received on 2019-04-15