{"thread":{"id":"63318","subject":"[PATCH 0/1] maintenance: fix launchctl calendar intervals","startedAt":"2025-04-21T05:48:58Z","lastAt":"2025-04-23T20:31:42Z","messageCount":5,"participants":["Josh Heinrichs","Junio C Hamano","Derrick Stolee"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"516417","messageId":"20250421054633.231069-1-joshiheinrichs@gmail.com","threadId":"63318","inReplyTo":null,"subject":"[PATCH 0/1] maintenance: fix launchctl calendar intervals","fromName":"Josh Heinrichs","fromEmail":"joshiheinrichs@gmail.com","sentAt":"2025-04-21T05:46:32Z","receivedAt":"2025-04-21T05:48:58Z","isPatch":true,"sender":{"key":"joshiheinrichs@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6166471?v=4"},"body":"Hello!\n\nWhile working to add git maintenance support to home-manager[1] on\nmacOS, I noticed that the calendar intervals are set up incorrectly for\nthe launchctl scheduler. With the current settings daily jobs run on the\nfirst six days of the month, and weekly jobs run daily. I've confirmed\nthis behaviour by manually shifting my system time around and checking\nthe system logs. This seems mostly harmless, and I think git maintenance\nis somewhat niche, so I don't think we need to worry about proactively\ncorrecting existing launchd configurations somehow.\n\n[1] https://github.com/nix-community/home-manager \n\nJosh Heinrichs (1):\n  maintenance: fix launchctl calendar intervals\n\n builtin/gc.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\n\nbase-commit: 683c54c999c301c2cd6f715c411407c413b1d84e\n-- \n2.47.2\n\n"},{"id":"516418","messageId":"20250421054633.231069-2-joshiheinrichs@gmail.com","threadId":"63318","inReplyTo":"20250421054633.231069-1-joshiheinrichs@gmail.com","subject":"[PATCH 1/1] maintenance: fix launchctl calendar intervals","fromName":"Josh Heinrichs","fromEmail":"joshiheinrichs@gmail.com","sentAt":"2025-04-21T05:46:33Z","receivedAt":"2025-04-21T05:48:59Z","isPatch":true,"sender":{"key":"joshiheinrichs@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6166471?v=4"},"body":"When using the launchctl scheduler, the weekly job runs daily, and the\ndaily job runs on the first six days of each month. This appears to be\ndue to specifying \"Day\" in the calendar intervals, which according to\nlaunchd.plist(5) is for specifying days of the month rather than days of\nthe week. The behaviour of running a job on the 0th day is undocumented,\nbut in my testing appears to be the same as not specifying \"Day\" in the\ncalendar interval, in which case the job will run daily.\n\nUse \"Weekday\" in the calendar intervals, which is the correct way to\nschedule jobs to run on specific days of the week.\n\nSigned-off-by: Josh Heinrichs <joshiheinrichs@gmail.com>\n---\n builtin/gc.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 99431fd467..cc13baa3bd 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -2075,7 +2075,7 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit\n \n \tcase SCHEDULE_DAILY:\n \t\trepeat = \"<dict>\\n\"\n-\t\t\t \"<key>Day</key><integer>%d</integer>\\n\"\n+\t\t\t \"<key>Weekday</key><integer>%d</integer>\\n\"\n \t\t\t \"<key>Hour</key><integer>0</integer>\\n\"\n \t\t\t \"<key>Minute</key><integer>%d</integer>\\n\"\n \t\t\t \"</dict>\\n\";\n@@ -2086,7 +2086,7 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit\n \tcase SCHEDULE_WEEKLY:\n \t\tstrbuf_addf(&plist,\n \t\t\t    \"<dict>\\n\"\n-\t\t\t    \"<key>Day</key><integer>0</integer>\\n\"\n+\t\t\t    \"<key>Weekday</key><integer>0</integer>\\n\"\n \t\t\t    \"<key>Hour</key><integer>0</integer>\\n\"\n \t\t\t    \"<key>Minute</key><integer>%d</integer>\\n\"\n \t\t\t    \"</dict>\\n\",\n-- \n2.47.2\n\n"},{"id":"516433","messageId":"xmqq1ptl76oh.fsf@gitster.g","threadId":"63318","inReplyTo":"20250421054633.231069-2-joshiheinrichs@gmail.com","subject":"Re: [PATCH 1/1] maintenance: fix launchctl calendar intervals","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-04-21T17:42:06Z","receivedAt":"2025-04-21T17:42:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Josh Heinrichs <joshiheinrichs@gmail.com> writes:\n\n> When using the launchctl scheduler, the weekly job runs daily, and the\n> daily job runs on the first six days of each month. This appears to be\n> due to specifying \"Day\" in the calendar intervals, which according to\n> launchd.plist(5) is for specifying days of the month rather than days of\n> the week. The behaviour of running a job on the 0th day is undocumented,\n> but in my testing appears to be the same as not specifying \"Day\" in the\n> calendar interval, in which case the job will run daily.\n>\n> Use \"Weekday\" in the calendar intervals, which is the correct way to\n> schedule jobs to run on specific days of the week.\n>\n> Signed-off-by: Josh Heinrichs <joshiheinrichs@gmail.com>\n> ---\n\nWith a bit wider context, the patch looks like so.  As I do not use\nmacOS or launchctl myself, my guess may be way off but please bear\nwith me.\n\n>  builtin/gc.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git i/builtin/gc.c w/builtin/gc.c\n> index 99431fd467..cc13baa3bd 100644\n> --- i/builtin/gc.c\n> +++ w/builtin/gc.c\n> @@ -2072,24 +2072,24 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit\n>  \t\tfor (i = 1; i <= 23; i++)\n>  \t\t\tstrbuf_addf(&plist, repeat, i, minute);\n>  \t\tbreak;\n>  \n>  \tcase SCHEDULE_DAILY:\n>  \t\trepeat = \"<dict>\\n\"\n> -\t\t\t \"<key>Day</key><integer>%d</integer>\\n\"\n> +\t\t\t \"<key>Weekday</key><integer>%d</integer>\\n\"\n>  \t\t\t \"<key>Hour</key><integer>0</integer>\\n\"\n>  \t\t\t \"<key>Minute</key><integer>%d</integer>\\n\"\n>  \t\t\t \"</dict>\\n\";\n>  \t\tfor (i = 1; i <= 6; i++)\n>  \t\t\tstrbuf_addf(&plist, repeat, i, minute);\n>  \t\tbreak;\n\nSo we used to say that \"we want the task to run on days 1 thru 6 (6\ndays in total) of a month at certain minute of the day past\nmidnight\", which clearly not how people think of \"daily\" task.\n\nUpdated one specifies the task to run on day 1 (Monday) thru 6\n(Saturday) of a week.  The manual page seems to say that day 0 and\nday 7 of a week are both Sundays.\n\n  https://www.manpagez.com/man/5/launchd.plist/ look for\n  StartCalendarInterval to read about Day and Weekday.\n\nCurious that day 7/0 are ignored.  Other schedulers are somewhat\ninconsistent but generally agree, so I won't worry about changing it\nin this patch.  schtasks_schedule_task() excludes Sundays, and\ncrontab_update_schedule() says that it wants to run daily scheduled\ntasks on day 1-6.  systemd_timer_write_timer_file() however seems to\nsay that it wants to run things on Tue..Sun (excluding Mondays),\nwhich may want to be corrected, I dunno.\n\n\n>  \tcase SCHEDULE_WEEKLY:\n>  \t\tstrbuf_addf(&plist,\n>  \t\t\t    \"<dict>\\n\"\n> -\t\t\t    \"<key>Day</key><integer>0</integer>\\n\"\n> +\t\t\t    \"<key>Weekday</key><integer>0</integer>\\n\"\n>  \t\t\t    \"<key>Hour</key><integer>0</integer>\\n\"\n>  \t\t\t    \"<key>Minute</key><integer>%d</integer>\\n\"\n>  \t\t\t    \"</dict>\\n\",\n>  \t\t\t    minute);\n>  \t\tbreak;\n\nThis one used to say \"run on 0th day of the month\", but now it says\n\"run on 0th day of the week\", which is on Sundays.  Makes sense.\n\nWill queue.  Thanks.\n"},{"id":"516630","messageId":"d5cdcfe0-5dd1-46ed-9860-a9949bd6b3b5@gmail.com","threadId":"63318","inReplyTo":"xmqq1ptl76oh.fsf@gitster.g","subject":"Re: [PATCH 1/1] maintenance: fix launchctl calendar intervals","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2025-04-23T19:25:11Z","receivedAt":"2025-04-23T19:25:13Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 4/21/2025 1:42 PM, Junio C Hamano wrote:\n> Josh Heinrichs <joshiheinrichs@gmail.com> writes:\n> \n>> When using the launchctl scheduler, the weekly job runs daily, and the\n>> daily job runs on the first six days of each month. This appears to be\n>> due to specifying \"Day\" in the calendar intervals, which according to\n>> launchd.plist(5) is for specifying days of the month rather than days of\n>> the week. The behaviour of running a job on the 0th day is undocumented,\n>> but in my testing appears to be the same as not specifying \"Day\" in the\n>> calendar interval, in which case the job will run daily.\n>>\n>> Use \"Weekday\" in the calendar intervals, which is the correct way to\n>> schedule jobs to run on specific days of the week.\n\nWow, good find! Thank you for submitting a fix for this issue.\n\nThanks,\n-Stolee\n\n"},{"id":"516636","messageId":"xmqqmsc6wrf8.fsf@gitster.g","threadId":"63318","inReplyTo":"d5cdcfe0-5dd1-46ed-9860-a9949bd6b3b5@gmail.com","subject":"Re: [PATCH 1/1] maintenance: fix launchctl calendar intervals","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-04-23T20:31:39Z","receivedAt":"2025-04-23T20:31:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Derrick Stolee <stolee@gmail.com> writes:\n\n> On 4/21/2025 1:42 PM, Junio C Hamano wrote:\n>> Josh Heinrichs <joshiheinrichs@gmail.com> writes:\n>> \n>>> When using the launchctl scheduler, the weekly job runs daily, and the\n>>> daily job runs on the first six days of each month. This appears to be\n>>> due to specifying \"Day\" in the calendar intervals, which according to\n>>> launchd.plist(5) is for specifying days of the month rather than days of\n>>> the week. The behaviour of running a job on the 0th day is undocumented,\n>>> but in my testing appears to be the same as not specifying \"Day\" in the\n>>> calendar interval, in which case the job will run daily.\n>>>\n>>> Use \"Weekday\" in the calendar intervals, which is the correct way to\n>>> schedule jobs to run on specific days of the week.\n>\n> Wow, good find! Thank you for submitting a fix for this issue.\n\nYes, good find indeed.  Tweaked in your Acked-by and will merge to\n'next'.\n\nThanks, all.\n"}]}