what does this code mean

I have the following code running as a crontab on a jboss server, could anyone explain each line, thanks.


for i in {1..20}
        #curl $(curl -k -i -m 10 https://xxx.xxx.com/jboss-status -k -i 2> /dev/null | grep "Location:" |sed 's/Location: //') > /var/www/html/f5-status 2> /dev/null
        curl -kLm 10 https://localhost/jboss-status > /var/www/html/f5-status 2> /dev/null
        sleep 15

Open in new window

Jason YuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Basically the script loops 20 times, and inside the loop retrieves the contents of the web page "https://localhost/jboss-status" via the curl utility.  The result is output to the file "/var/www/html/f5-status", and errors are disposed of.  A ten second timeout is used on the curl command, an insecure connection is allowed, and if the page has move and redirects to the new location that will be followed.  A 15 second delay is added to each pass of the loop before getting the page content again.

The # indicates a comment in bash, so the first curl line has been commented out.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gerwin Jansen, EE MVETopic Advisor Commented:
The first line means that the script is being executed by the /bin/bash shell. Minor note on the output, it is overwritten each time because of the single > If you would retain output of each check add another Iike this :

... >> /var/www ...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.