Advertisement
Guest User

Untitled

a guest
May 11th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. dir_data="/home/test/.fortcronjob/"
  2.  
  3. if [ $# != 2 ]
  4. then
  5. echo "Usage: unique_id week_modulus"
  6. exit 1
  7. fi
  8.  
  9. instance_id=$1
  10. instance_mod=$2
  11. counter=0
  12. exit_value=1
  13. file_data="$dir_data$1"
  14.  
  15. if [ ! -e "$file_data" ]
  16. then
  17. echo "id:$instance_id - no data, starting from 0"
  18. else
  19. source "$file_data"
  20. fi
  21.  
  22. counter=$(( $counter % $instance_mod ))
  23.  
  24. if [ $counter == 0 ]
  25. then
  26. echo "id:$instance_id - true"
  27. exit_value=0
  28. else
  29. echo "id:$instance_id - t-$(( $instance_mod - $counter ))"
  30. fi
  31.  
  32. counter=$(( $counter + 1 ))
  33. echo "counter=$counter" > "$file_data"
  34.  
  35. exit $exit_value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement