Fork a thread and kill the thread after sleeping for 1 sec in the parent, in the provided example the command produces measurable contents that allow the number of runs to be counted.
This sounds to homework-esque to provide implementation details.
@Skrynesaver : Sounds latin n greek to me !!!!!
I dont really have any significant knowledge about FORKS
and THREADS .
Are there any reference manuals that may be helpful in this regard ?
I interpret your question this way - You have a need to execute a command continuously for X seconds and find out how many times the command runs successfuly within that period of X seconds. And you have X as 1 now.
Below is one approach but consider the execution time of these extra commands - date, if $? -eq 0 - which may consume some extra time if you want to measure the performance of your command.
CURR_SECS=$(date +%s)
while $CURR_SECS -lt $CURR_SECS + 1
do
echo Hi
if [ $? -eq 0 ]
then
SUCCESS_COUNT=$(expr $SUCCESS_COUNT + 1)
fi
CURR_SECS=$(date +%s)
done
Note: This is not tested and might have syntax errors.