wzul

PaperTrail Download Logs

May 5th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.71 KB | None | 0 0
  1. #!/bin/bash
  2. # this is bash version of https://pastebin.com/w6Dt3ZeY
  3. papertrailkey=""
  4.  
  5. now=`date +"%Y-%m-%d" -d "04/01/2019"`
  6. end=`date +"%Y-%m-%d" -d "05/01/2019"` #Must end +1 from the last date
  7.  
  8. while [ "$now" != "$end" ] ;
  9. do
  10.   hour=0
  11.   counter=0
  12.   while [ $hour -le 23 ]
  13.   do
  14.     hourformatted=$(printf "%02d" $hour)
  15.     datetime="$now-$hourformatted"
  16.     header="--header=X-Papertrail-Token: $papertrailkey"
  17.     wget "$header" -O "$datetime.tsv.gz" "https://papertrailapp.com/api/v1/archives/$datetime/download" &
  18.     if  [ "1" = "$counter" ];
  19.     then
  20.       counter=0
  21.       wait
  22.     fi
  23.     hour=$(( $hour + 1))
  24.     counter=$(( $counter + 1))
  25.   done
  26.   now=`date +"%Y-%m-%d" -d "$now + 1 day"`;
  27. done
Add Comment
Please, Sign In to add comment