Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. clean_up() {
  4. echo "clean up..."
  5. PID=$(pidof redis-server)
  6. if [ $? != 1 ]; then
  7. kill -9 $PID
  8. fi
  9. }
  10.  
  11. trap clean_up SIGINT
  12.  
  13. run_it() {
  14. echo "runing..."
  15. if [ -f ../redis.conf ]; then
  16. redis-server ../redis.conf &
  17. return 0
  18. else
  19. echo "without config file"
  20. return 1
  21. fi
  22. }
  23.  
  24. do_benchmark() {
  25. echo "do benchmark"
  26. pidof redis-server
  27. if [ $? != 1 ]; then
  28. redis-benchmark > benchmark$(date +%s).list
  29. fi
  30. }
  31.  
  32. ready() {
  33. sysctl -w vm.drop_caches=3
  34. swapoff -a
  35.  
  36. if [ -d benchmark$(date +%d) ]; then
  37. pushd benchmark$(date +%d)
  38. else
  39. mkdir benchmark$(date +%d)
  40. pushd benchmark$(date +%d)
  41. fi
  42. echo "let go.."
  43. }
  44.  
  45. main() {
  46. ready
  47. run_it
  48. if [ $? == 0 ]; then
  49. do_benchmark
  50. clean_up
  51. else
  52. clean_up
  53. fi
  54. }
  55.  
  56. main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement