do sleep

closed account (oj2wbRfi)
how this command: for i in {1..5}; do sleep 600 & done
work?
for i in {1..5}; do something done

That's a for loop in bash. The something can be a single statement, or a group of statements run in a sub-shell with ().

A trivial example is:
 
for i in {1..3}; do echo "i=$i"; done

i=1
i=2
i=3


The next part of your question is looking at the actual something, sleep 600 &

Most modern shells can run a program in the background. There something called "Job Control" that covers how shells deal with this. There's always one foreground task, if nothing's running, it's the shell, but you can have zero or more background tasks. You can see your background tasks with jobs.
https://www.gnu.org/software/bash/manual/html_node/Job-Control-Basics.html

To background a task, prepend it with &. You can also background the foreground task by typing Ctrl-z.

And as for sleep 600?
https://man7.org/linux/man-pages/man1/sleep.1.html
Last edited on
Topic archived. No new replies allowed.