~alpine/users

3 3

Problem with crontab

Wolfgang Klein <klein.wolfg@web.de>
Details
Message ID
<9e46853a-fcdd-5673-d243-65c244026117@web.de>
DKIM signature
missing
Download raw message
Hello,

in my crontab there are these two entries:


7,37	0-7,18-23	*	*	1-5	command
7,37	*		*	*	6,7     command


"Command" needs to be executed every 30 minutes, *except* during office 
hours. That's why there are two lines: one that's to be executed Monday 
to Friday, and one on Saturday and Sunday.

On Ubuntu, this has been working perfectly as expected for years now. On 
Alpine, the DOW field seems to be ignored somehow: "command" is executed 
every 30 minutes on each day of the week! It seems that the second call 
is executed regardless of the DOW entry.

Does cron on Alpine need a different syntax? Does it not know about the 
DOW option?

Thanks in advance for any help!


Regards,

Wolfgang
Andreas Kähäri <andreas.kahari@abc.se>
Details
Message ID
<aLNRKqAdhkagEeaR@eeyore.invalid>
In-Reply-To
<9e46853a-fcdd-5673-d243-65c244026117@web.de> (view parent)
DKIM signature
missing
Download raw message
On Sat, Aug 30, 2025 at 08:58:05PM +0200, Wolfgang Klein wrote:
> Hello,
> 
> in my crontab there are these two entries:
> 
> 
> 7,37	0-7,18-23	*	*	1-5	command
> 7,37	*		*	*	6,7     command
> 
> 
> "Command" needs to be executed every 30 minutes, *except* during office
> hours. That's why there are two lines: one that's to be executed Monday to
> Friday, and one on Saturday and Sunday.
> 
> On Ubuntu, this has been working perfectly as expected for years now. On
> Alpine, the DOW field seems to be ignored somehow: "command" is executed
> every 30 minutes on each day of the week! It seems that the second call is
> executed regardless of the DOW entry.
> 
> Does cron on Alpine need a different syntax? Does it not know about the DOW
> option?
> 
> Thanks in advance for any help!
> 
> 
> Regards,
> 
> Wolfgang
> 
> 

The busybox cron does not understand "7" as a valid day of the
week. The Vixie cron daemon allows for using either "0" or "7"
as Sunday, but busybox cron only allows "0" for Sunday (as per
POSIX).

So you need to change your second line to:

	7,37  *  *  *  6,0  command

I ran into this myself a while ago and decided to look deeper into the
busybox cron source code to confirm this.

See my issue and resolution here:

	https://unix.stackexchange.com/questions/783517

-- 
Matti Andreas Kähäri (Kusalananda)
Uppsala, Sweden

.
Wolfgang Klein <klein.wolfg@web.de>
Details
Message ID
<27ed3dc2-1552-ddd5-c3bd-2effbc6cc79f@web.de>
In-Reply-To
<aLNRKqAdhkagEeaR@eeyore.invalid> (view parent)
DKIM signature
missing
Download raw message
Here's a big THANK YOU, Andreas! :)


Cheers,
Wolfgang
Prabu Anand Kalivaradhan <kprabuanand@gmail.com>
Details
Message ID
<CAAt6f0YZcms=Rfo45QbQ2VyAtqc7fGvdnVkRF_KvGZNYSOHmsw@mail.gmail.com>
In-Reply-To
<aLNRKqAdhkagEeaR@eeyore.invalid> (view parent)
DKIM signature
missing
Download raw message
Thanks for the note, Andreas.  wiki <https://wiki.alpinelinux.org/wiki/Cron>
 updated.

On Sun, 31 Aug 2025 at 01:00, Andreas Kähäri <andreas.kahari@abc.se> wrote:

> On Sat, Aug 30, 2025 at 08:58:05PM +0200, Wolfgang Klein wrote:
> > Hello,
> >
> > in my crontab there are these two entries:
> >
> >
> > 7,37  0-7,18-23       *       *       1-5     command
> > 7,37  *               *       *       6,7     command
> >
> >
> > "Command" needs to be executed every 30 minutes, *except* during office
> > hours. That's why there are two lines: one that's to be executed Monday
> to
> > Friday, and one on Saturday and Sunday.
> >
> > On Ubuntu, this has been working perfectly as expected for years now. On
> > Alpine, the DOW field seems to be ignored somehow: "command" is executed
> > every 30 minutes on each day of the week! It seems that the second call
> is
> > executed regardless of the DOW entry.
> >
> > Does cron on Alpine need a different syntax? Does it not know about the
> DOW
> > option?
> >
> > Thanks in advance for any help!
> >
> >
> > Regards,
> >
> > Wolfgang
> >
> >
>
> The busybox cron does not understand "7" as a valid day of the
> week. The Vixie cron daemon allows for using either "0" or "7"
> as Sunday, but busybox cron only allows "0" for Sunday (as per
> POSIX).
>
> So you need to change your second line to:
>
>         7,37  *  *  *  6,0  command
>
> I ran into this myself a while ago and decided to look deeper into the
> busybox cron source code to confirm this.
>
> See my issue and resolution here:
>
>         https://unix.stackexchange.com/questions/783517
>
> --
> Matti Andreas Kähäri (Kusalananda)
> Uppsala, Sweden
>
> .
>
Reply to thread Export thread (mbox)