As a beginner Linux user I'm facing with the little problem. I have 1 command in terminal like in the picture:  When I run this command it will generate some lines, but the problem is I need to make this command stops after 5 seconds without actually pressing ctrl + c by human :What methods I need to use to make this done by computer without actually pressing ctrl + c because I need to repeat this process over 1000 times.  run command stop command  (pause xx seconds) run command stop command(pause xx seconds)etc.Do I need to install some special programs or it can be done using bash scripting?
Run/stop command in terminal without human interference?
linux;shell script;shell;command line;terminal
You can run the command in the background and then sleep for 5 seconds in the foreground and then kill the background command.Run the command in the background:command &Save the command PID in a variable:command_pid=$!Sleep for 5 secs:sleep 5Kill the background process:kill $command_pidNow you can add a pause and put the whole in a loop, etc.Loop:for ((i=0; i<1000; i++)); do    crunch 7 7 abcdefghijklm &    command_pid=$!    sleep 5    kill $command_pid    sleep 5 #pausedone