Add special times support to crond
Jonathan Kolb
kolbyjack at gmail.com
Sat Jul 8 19:46:37 UTC 2017
That works for me here, and looks much better, thanks!
On Sat, Jul 8, 2017 at 2:52 PM, Denys Vlasenko <vda.linux at googlemail.com> wrote:
> On Thu, Jun 22, 2017 at 8:24 PM, Jonathan Kolb <kolbyjack at gmail.com> wrote:
>> I recently started using Alpine Linux, and ran into an issue where my
>> user could no longer use the @reboot cron feature to define its own
>> startup jobs. Attached is a patch to add support for the named times
>> found here: https://linux.die.net/man/5/crontab.
>>
>> size -A -d miscutils/crond.o change:
>> section original patch
>> .rodata.str1.1 693 775
>> .text.start_jobs 0 382
>> .text.load_crontab 804 1031
>> .text.crond_main 1535 1363
>> .rodata 0 50
>> .rodata.SpecAry 0 144
>> Total 4953 5666
>
> The patch does not apply.
>
> flag_reboot_jobs() is redundant, you can flag reboot jobs as wanting to start
> as you create them. This also makes ->cl_Reboot field redundant.
>
> + if (access(CRON_REBOOT, R_OK | W_OK) == -1) {
> + close(open(CRON_REBOOT, O_WRONLY | O_CREAT, 0000));
>
> No need to access(). Just open(O_EXCL) it. If you get >= 0,
> the file did not exist.
>
> + { "yearly", "0\0" "0\0" "1\0" "1\0" "*" },
> + { "annually", "0\0" "0\0" "1\0" "1\0" "*" },
> + { "monthly", "0\0" "0\0" "1\0" "*\0" "*" },
> + { "weekly", "0\0" "0\0" "*\0" "*\0" "0" },
> + { "daily", "0\0" "0\0" "*\0" "*\0" "*" },
> + { "midnight", "0\0" "0\0" "*\0" "*\0" "*" },
> + { "hourly", "0\0" "*\0" "*\0" "*\0" "*" },
>
> You need not specify "minutes" field, it is "0" for all of them.
>
> + for (int i = 0; i < 5; ++i)
> + tokens[i] = (char *)e->tokens + 2 * i;
>
> How about:
>
> + char *et =
> (char*)e->tokens;
> + /* minute is
> "0" for all specials */
> + tokens[0] = (char*)"0";
> + tokens[1] = et;
> + tokens[2] = et + 2;
> + tokens[3] = et + 4;
> + tokens[4] = et + 6;
>
>
> + tokens[5] =
> parser->data + strspn(parser->data, DELIMS);
> + tokens[5] +=
> strcspn(tokens[5], DELIMS);
> + tokens[5] +=
> strspn(tokens[5], DELIMS);
>
> Oh no...
>
> How about doing it like in attached patch? I did not test it...
More information about the busybox
mailing list