LoginSignup
0
1

More than 3 years have passed since last update.

cronを一定確率で実行する

Last updated at Posted at 2021-03-02
crontab -e
# 毎分1%の確率でecho hoge
* * * * * [ $((RANDOM \% 100)) -eq 1 ] && echo hoge

# 毎分33%の確率でecho hoge
* * * * * [ $((RANDOM \% 100)) -lt 33 ] && echo hoge

味噌は「%」にはエスケープが必要ということです。
ハマったので誰かの助けになれば幸いです。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1