cron 设置随机时间执行
__set_cron() {
_path="/etc/cron.d/test"
cat >$_path <<"EOF"
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
* * * * * root sleep $(shuf -i "5-55" -n 1); echo "每分钟的第5秒到55秒, 随机一秒执行$(date)" > /tmp/cron_test.txt
*/5 * * * * root sleep $(shuf -i "1-240" -n 1); echo "5分钟一次, 4分钟内的随机时间执行(留一分钟执行时间)" > /tmp/cron_test.txt
EOF
chmod 644 $_path
}
__set_cron