1. __random_date() {
    2. min=$1
    3. max=$(($2 - $min + 1))
    4. num=$(date +%s%N)
    5. echo $(($num % $max + $min))
    6. }
    7. __set_cron() {
    8. _random=$(__random_date 1 59)
    9. _path=/etc/cron.d/cron_job
    10. cat >$_path <<-'EOF'
    11. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    12. */1 * * * * root sleep @@@; bash /apps/shell/job.sh >> /dev/null
    13. EOF
    14. sed -i "s/@@@/$_random/g" $_path
    15. chmod 644 $_path
    16. }
    17. __set_cron