---
slug: "shell-script-sleep-in-loop-after-first"
title: "Sleep after the second loop in a shell script"
description: "When processing redundant items one by one in sequence, to ensure not to process everything at once, you can use a sleep function after the second loop iteration and onwards."
url: "https://www.ytyng.com/en/blog/shell-script-sleep-in-loop-after-first"
publish_date: "2023-07-20T11:48:32Z"
created: "2023-07-20T11:48:32Z"
updated: "2026-02-27T03:16:10.707Z"
categories: []
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20250705/fb3c878e9e794915b7a3edf1cf9c9b8f.png.webp?width=768"
has_video: true
has_music: true
video_urls: ["https://media.ytyng.net/ytyng-blog/288/featured-video-1.mp4", "https://media.ytyng.net/ytyng-blog/288/featured-video-2.mp4", "https://media.ytyng.net/ytyng-blog/288/featured-video-3.mp4"]
music_urls: ["https://media.ytyng.net/ytyng-blog/288/featured-music-288-3.mp3", "https://media.ytyng.net/ytyng-blog/288/featured-music-288-4.mp3"]
lang: "en"
---

# Sleep after the second loop in a shell script

Here's the translation of the provided Japanese blog article into English:

---

When processing redundant items one by one, you may need to sleep after the second loop to avoid doing everything at once.

```shell
#!/usr/bin/env zsh

sleep_command=""
for i in {1..3} ; do
    eval ${sleep_command}
    echo ${i}
    sleep_command="sleep 10"
done
```

---
