Curl command parameters and Curl monitoring Web OK Auto Restart Application Script Example

Source: Internet
Author: User
Tags http authentication

First Curl Monitoring web automatic Restart script (this one interface call, only consider the case of return code 200)

#!/bin/bash check_ip= "x.x.x.x" check_port= "6500" logdir= "/data/log/check/" log= "$logdir/check_interface.log" #指定json格式post的方式去提交到服务器 #check_status=$ (curl -i -h  ' Content-type: application/json '  -X  POST -d  ' {"IMEI":  "123456", "Plate":  "os_android", "brand":  "Sumsung"} '  -w   -i -m 10 -o /dev/null -s -w %{http_code}  http://$ CHECK_IP: $check _port/online/agentinfo/732459/mtqxntyznti4oa==bw9i2d2312e82cf87e12easdasdasda6150) # Default get way to commit to server check_status=$ (curl -o /dev/null -s -w %{http_code} http://$check _ IP: $check _port/verdict/session/lsgja5ssdd55974/latest/result) Datef ()  { date  "+%y/%m/%d %h: %m:%s " ; }print_to_log ()  { echo " [$ (DATEF)] $1 " >>  $LOG  ;  }[[ -d  $logdir   ]] | |  mkdir  -p  $logdirif  [[  $check _status  -ne 200    ]];thenprint_to_log  "XX service has stopped responding." cd /data/www/apps/data-camp/bin sh boxrun  stoppid=$ (ps aux |grep  jrdt-online |grep -v grep  |wc -l) if [[  $pid  -eq 0 ]]; thenprint_to_log  "=>1.xx service normal Stop" sh boxrun  start  pidnext=$ (ps aux | GREP&NBSP;JRDT-ONLINE&NBSP;|GREP&NBSP;-V&NBSP;GREP&NBSP;&NBSP;|WC&NBSP;-L)   if [[  $pidnext  -ne 0   ]];then         /usr/bin/cagent _tools alarm   "Production environment: XX Service stop responding, restart OK"             print_to_log  "=>2.xx service starts normally!"   else        /usr/bin/cagent_tools alarm   " Production environment: XX Service stops responding, restart not OK, please log on to the server immediately to see.         print_to_log  "<=>2.xx service failed to start!"             fi fielse print_to_log  "xx service normal." Fi

The Curl command uses the example

# #基本用法 (with Sed/awk/grep)   $curl  http: //s.worthsee.com# #下载保存   $curl  http://s.worthsee.com  > index.html  $curl  -o index.html http://s.worthsee.com  $curl  -o  http://s.worthsee.com/target.tar.gz# #通过代理   $curl  -x 123.45.67.89:1080 -o  page.html http://s.worthsee.com# #保存cookie   $curl  -x 123.45.67.89:1080 -o  page1.html -d cookie0001.txt http://s.worthsee.com# #使用cookie   $curl  -x  123.45.67.89:1080 -o page1.html -d cookie0002.txt -b cookie0001.txt http:// s.worthsee.com# #模仿浏览器   $curl  -A  "mozilla/4.0  (compatible; msie 6.0; windows  nt 5.0) " -x123.45.67.89:1080 -o page.html -d cookie0001.txt http:// s.worthsee.com# #伪造referer   $curl  -A  "mozilla/4.0  (compatible; msie 6.0;  windows nt 5.0) " -x123.45.67.89:1080 -e "Mail.worthsee.com"  -o page.html -d cookie0001.txt http:// s.worthsee.com# #循环下载   $curl  -o http://s.worthsee.com/~zzh/screen[1-10]. jpg# #循环 (match) Download   $curl  -o http://s.worthsee.com/~{zzh,nick}/[001-201]. jpg  # >like zzh/001.jpg# #循环 (citation) download   $curl  -o  #2_ #1.jpg http:// S.WORTHSEE.COM/~{ZZH,NICK}/[001-201]. jpg # like >001_zzh.jpg# #断点续传   $curl  -c -o http://s.worthsee.com/~zzh/ Screen1. jpg# #分块下载   $curl  -r  0 -10240  -o  "Zhao.part1"   http:// s.worthsee.com/~zzh/zhao1.mp3 &  $curl  -r 10241 -20480  -o  " Zhao.part1 "  http://s.worthsee.com/~zzh/zhao1.mp3 &  $curl  -r 20481 - 40960  -o  "Zhao.part1"   http://s.worthsee.com/~zzh/zhao1.mp3 &  $curl  -r 40961 - -o   "Zhao.part1"   http://s.worthsee.com/~zzh/zhao1.mp3 ...  $cat  zhao.part* > zhao.mp3## get  upload   $curl  http://www.worthsee.com/login.cgi?user=nickwolfe&password=12345# #POST   Upload   $curl  -d  "user=nickwolfe&password=12345"  http://www.worthsee.com/login.cgi# #POST   File upload   $curl  -f [email protected]  -f btn_name=btn_value http:// s.worthsee.com/~zzh/up_file.cgi

Curl Command Parameters

-a/--append  when uploading a file, attach to target file  -A/--user-agent <string>   set user agent to send to server  -  anyauth    can use "any" authentication method  -b/--cookie <name=string/file> cookie string or file read location  - basic  using HTTP Basic authentication  -B/--use-ascii  using ascii /text transfer  -c/--cookie-jar < file>  the cookie to this file after the end of the Operation  -C/--continue-at <offset>   Breakpoint continuation  -d/--data  <data>   http post Way to transfer data  --data-ascii <data>   Post data in ASCII mode  --data-binary <data>  post data in binary mode  --negotiate       using HTTP authentication  --digest         using digital authentication  -- disable-eprt   prohibit the use of eprt or lprt --disable-epsv   prohibit the use of epsv -d/--dump-header < file>  writes header information to the file  --egd-file <file>  sets Egd socket path for random data (SSL)  -- tcp-nodelay    using Tcp_nodelayOptions  -e/--referer  Source URL  -e/--cert <cert[:p asswd]>  client certificate file and password   (SSL)  -- cert-type <type>  certificate file type   (Der/pem/eng)   (SSL)  --key <key>       private key filename   (SSL)  --key-type <type>  private key file type   (Der/pem/eng)   (SSL)  --pass  <pass>   private Key Password   (SSL)  --engine <eng>   Encryption engine uses   (SSL) .  "--engine list" &NBSP;FOR&NBSP;LIST&NBSP;--CACERT&NBSP;&LT;FILE&GT;&NBSP;CA Certificate   (SSL)  --capath <directory> ca directory   (Made using c_rehash)  to  verify peer against  (SSL)  --ciphers <list>  ssl password  --compressed      requirements return is compressed in the situation   (Using deflate or gzip)  --connect-timeout  <seconds>  set maximum request time  --create-dirs    Create a directory hierarchy of local directories  --crlf            upload is to convert LF into crlf -f/--fail           Do not display HTTP error when connection fails  --ftp-create-dirs  create remote directory If remote directory does not exist &NBSP;--FTP-METHOD&NBSP;[MULTICWD/NOCWD/SINGLECWD]   Controlling the use of CWD  --ftp-pasv       using  PASV/EPSV  instead of Port  -- ftp-skip-pasv-ip  when using PASV, ignore the IP address  --ftp-ssl        try to use  ssl/ tls  FTP data transfer  --ftp-ssl-reqd   require  SSL/TLS  for FTP data transfer  -F/--form < name=content>  analog HTTP form submission Data  -form-string <name=string>  analog HTTP form submission data  -g/-- globoff  disabling URL sequences and ranges use {} and [] -g/--get  to send data in Get- -h/--help  help  -H/--header  <line> Custom header information passed to server  --ignore-content-length   ignored length of HTTP header information  -i/--include  Include protocol header information at output  -I/--head   Show only Document information   read from file-j/--junk-session-cookies ignore session cookie -  Interface <interface> Specify network interface/address using  - krb4 < level > Enable krb4 -j/--junk-session-cookies  read files with the specified security level ignore Session cookie --interface  <interface>  using the specified network interface/address  --krb4 <level>   krb4 -k/--with the specified security level insecure  allows you to not use certificates to SSL sites  -K/--config   specified profile reads  -l/--list-only  lists file names under the FTP directory   --limit-rate <rate>  Set transfer speed  --local-port<NUM>  enforce use of local port number  -m/--max-time  <seconds>  set Maximum transfer time  --max-redirs <num>  set the maximum number of read directories  --max-filesize  <bytes>  set the maximum amount of files to download  -M/--manual   show full manual  -n/--netrc  read user names and passwords from the Netrc file  --netrc-optional  use  .netrc  or  url to cover-n --ntlm            Use  HTTP NTLM  authentication  -N/--no-buffer  disable buffered output  -o/-- output  writes the output to the file  -O/--remote-name  writes the output to the file, preserving the file name of the remote files  -p/--proxytunnel    Using HTTP proxy  --proxy-anyauth&nbspSelect either proxy authentication method  --proxy-basic    use Basic authentication on proxy  --proxy-digest   use digital authentication on proxy  --proxy-ntlm     use NTLM authentication on the agent  -P/--ftp-port <address>  use port address, Instead of using pasv -q/--quote <cmd> file transfer, send command to server  -r/--range <range> retrieve from http/ 1.1 or FTP server byte range  --range-file  read (SSL) random files  -R/--remote-time    Preserve remote file time when generating files locally  --retry <num>    number of retries when there is a problem with transmission  --retry-delay <seconds>    When a problem occurs with transmission, set the maximum retry time  -s/--silent silent mode when setting the retry interval  --retry-max-time <seconds>  transmission problem. Do not output anything  -S/--show-error    display error  --socks4 


Curl command parameters and Curl monitoring Web OK Auto Restart Application Script Example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.