Guest User

cron

a guest
Oct 8th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  3.  
  4. WGET=` which wget `
  5. SED=` which sed `
  6. RM=` which rm `
  7. CAT=` which cat `
  8. COPY=` which cp `
  9. GREP=` which grep `
  10. AWK=` which awk `
  11. UNZIP=` which unzip `
  12. ZIP=` which zip `
  13. MOVE=` which mv `
  14.  
  15. download-data-zip()
  16. {
  17.     echo "downloading data zip"
  18.     ./auto_SCP.sh root@x.x.x.x:/home/name/data/data-3.0.zip ./
  19.     echo "downloaded data zip."
  20. }
  21.  
  22. create-new-data-zip()
  23. {
  24.     echo "extracting data zip..."
  25.     /usr/bin/unzip data-3.0.zip
  26.     echo "extracted. removing old signatures file and xml files.."
  27.     $RM ./data-3.0/abc/file1
  28.     $RM ./data-3.0/xyz/*.xml
  29.     echo "copying new file"
  30.     $COPY ./file1 ./data-3.0/abc/
  31.     echo "copied."
  32.     curYr=$(date +%Y)
  33.     echo "current year=$curYr"
  34.     if [ ! -s yrFile ]
  35.     then
  36.         echo "yrFile is empty"
  37.         for yr in $(seq 2002 $curYr)
  38.         do
  39.             echo $yr "going to " yrFile
  40.             echo $yr >> yrFile
  41.         done
  42.     fi
  43.     randNum=$(/usr/bin/shuf -n 1 yrFile)
  44.     echo "random number=$randNum"
  45.     echo "removing random year from yrFile and copying 2 xml files..."
  46.     $SED "/$randNum/d" yrFile > yrFile1
  47.     $MOVE yrFile1 yrFile
  48.     $COPY ./cde/e-${randNum}.xml ./data-3.0/xyz/
  49.     $COPY ./cde/e-${curYr}.xml ./data-3.0/xyz/
  50.     /usr/bin/zip -Dr9 data-3.0.zip data-3.0
  51.     echo "new data zip created."
  52. }
  53.  
  54. main()
  55. {
  56. cd /root/Test/
  57. echo -n "" > /root/Test/cronOutput
  58.     download-data-zip
  59.     create-new-data-zip
  60. }
  61.  
  62. main
Advertisement
Add Comment
Please, Sign In to add comment