[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: notify via virtual terminal available packages



On Thu, Sep 24, 2020 at 08:10:04AM -0600, Charles Curley wrote:
> On Thu, 24 Sep 2020 09:53:59 -0400
> Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> 
> > RANDOM is a bashism, not available in sh, so that won't work in a
> > crontab unless you've altered which shell cron is using to parse the
> > crontab.
> 
> Well, that's interesting. The file I pulled that from (in /etc/cron.d)
> sets two variables explicitly:
> 
> SHELL=/bin/sh
> PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> 
> And the machine that it runs on shows:
> 
> root@hawk:~# ll /bin/sh
> lrwxrwxrwx 1 root root 4 Jan 17  2019 /bin/sh -> dash*

In dash, RANDOM does nothing; it's just an empty variable.  And as it
turns out, dash treats that as a zero.

unicorn:~$ dash
$ echo $((1 + RANDOM % 1200))
1
$ echo $((1 + % 1200))
dash: 2: arithmetic expression: expecting primary: "1 + % 1200"
$ echo $((1 + XYZZY % 1200))
1

So you're just doing "sleep 1" every time.


Reply to: