Computer Science, asked by amitesh01kuma, 1 year ago

UNIX command to wait for a specified number of seconds before exit.

Answers

Answered by empathictruro
0

#!/bin/bash

/opt/abc/bin/stop

# Wait for 10 second

sleep 10

# Number of seconds to wait

WAIT_SECONDS=300

# Counter to keep count of how many seconds have passed

count=0

while pgrep abc_test > /dev/null

do

   echo "server is still running."

   # Wait for one second

   sleep 1

   # Increment the second counter

   ((count++))

   # Has the process been killed? If so, exit the loop.

   if ! pgrep abc_test > /dev/null ; then

       break

   fi

   # Have we exceeded $WAIT_SECONDS? If so exit the loop

   if [ $count -gt $WAIT_SECONDS ]; then

       break

   fi  

done

Answered by Arslankincsem
2

The command to wait for a specified number of seconds before the exit that can be used is ‘wait for *sec*’, here *sec*, means time in seconds.

For example, to wait for 10 seconds before exit you may write it as, wait for 5.

The other command that one can also use is to use the sleep command as ‘sleep *sec*’. For example, sleep 5, which makes 5 seconds delays before exit.

Similar questions