bash tips

bash デフォルト値
#!/bin/bash

foo=${1:-hoge}
echo $foo #$1がなかったらhogeをデフォルト値としてfooに代入する

https://gist.github.com/doi-t/7853853

bash ループ
items[0]="altair"
items[1]="betelgeuse"
items[2]="canopus"

for item in "${items[@]}" ; do
    echo "[ ${item} ]"
done

https://qiita.com/ytyng/items/d7afe80ef9da7aa8b721

sleep RANDOM

To scale that number to the range of seconds you want to delay starting your cron job, do some modulo arithmetic. For example, to wait for a random time between 0 and 600 seconds (= 10 minutes) before running your job, do:

sleep $(( RANDOM % 600 )); /path/to/executable

https://www.endpoint.com/blog/2020/06/randomly-spacing-cron-jobs/