Advertisement
Kala666

task.sh

Apr 19th, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.43 KB | None | 0 0
  1. # !/bin/bash
  2.  
  3. if [ -z "$3" ]; then
  4.     echo "Usage: $0 <task-id> <exec-time-in-seconds>"
  5.     exit 1
  6. fi
  7.  
  8. echo "Task $1 starting, execution time is $2, will-fail is $3"
  9.  
  10. for i in `seq 1 $2`; do
  11.     echo "Task $1 tick - $i"
  12.     sleep 1
  13. done
  14.  
  15. if [ "$3" == "1" ]; then
  16.     # Write to stderr and exit
  17.     echo "** ERROR ** Task $1 failed! exiting with error." 1>&2
  18.     exit 1
  19. fi
  20.    
  21. echo "Task $1 done, exiting with success."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement