$() is POSIX and supported by all modern Bourne shells, e.g. ksh, bash, ash, dash, zsh, busybox, you name it. (A not so modern one is Solaris /bin/sh, but on Solaris you would make sure to use the modern /usr/xpg4/bin/sh instead). –
Jens CommentedMay 17, 2012 at 18:54
FreeBSD の crontab ( /bin/sh ) は $() 使える
Legacy Bourne shell backticks ``:
sleep `jot -r 1 0 2700`
$() → 見やすくなる
sleep $(jot -r 1 0 2700)
例
- name: Add random sleep to periodic jobs in /etc/crontab ansible.builtin.replace: path: /etc/crontab regexp: "{{ item.regexp }}" replace: "{{ item.replace }}" loop: - regexp: '^1\t3\t\*\t\*\t\*\troot\tperiodic daily$' replace: "1\t3\t*\t*\t*\troot\tsleep $(jot -r 1 0 2700); periodic daily" - regexp: '^15\t4\t\*\t\*\t6\troot\tperiodic weekly$' replace: "15\t4\t*\t*\t6\troot\tsleep $(jot -r 1 0 2700); periodic weekly" - regexp: '^30\t5\t1\t\*\t\*\troot\tperiodic monthly$' replace: "30\t5\t1\t*\t*\troot\tsleep $(jot -r 1 0 2700); periodic monthly"