I have a program that takes a variable time to run (no more than two minutes), and to make it less odious, I put fortune messages.
#!/bin/bash
...
for i in $(seq 1 45); do sleep 3; echo; echo; fortune; done &
...
However, the program duration may vary (depending on factors that are irrelevant here) and need to stop the messages.
#!/bin/bash
...
for i in $(seq 1 45); do sleep 3; echo; echo; fortune; done &
...
if [any-condition]; Then
#script is over... Stop messages!!!
fi
...
if [any-condition]; Then
#Stop messages... script continue execution
fi
... Blah blah
...
#script is over stop Messages!
So if I prepare 45 messages in periods of 3 seconds, the program may end soon but the messages still appear in the terminal, interfering with other work.
I try with command jobs
, but there are no jobs in background. Try with command ps
but can't found the messages task.
How to stop that fortune messages?