On Wed, Sep 01, 2021 at 04:39:54PM +0200, Adam Paulukanis wrote: | On Wed, 1 Sept 2021 at 16:32, Christian Weisgerber <na...@mips.inka.de> wrote: | > | > Goetz Schultz: | > | > > I would go the other way and check tomorrows date. If it is "01", then I | > > know today is the last of this month: | > > | > > date --date="tomorrow" +%d | > > 02 | > | > That's not OpenBSD. | > | > $ date --date="tomorrow" +%d | > date: unknown option -- - | > usage: date [-aju] [-f pformat] [-r seconds] | > [-z output_zone] [+format] [[[[[[cc]yy]mm]dd]HH]MM[.SS]] | > | | | Not sure if it is OpenBSD. I am on Darwin right now | | $ date -v+1d +%d # if today is the last day of the month, tomorrow will be 1st.
This will work on OpenBSD: [ $(date -r $(($(date +%s) + 86400)) +%e) -eq 1 ] || exit 0 <rest of your script here> Although you'll have to be cautious with tricks like these to run this only between 01:00 and 23:00 if your system runs with a timezone that has daylight savings time. Cheers, Paul 'WEiRD' de Weerd -- >++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+ +++++++++++>-]<.>++[<------------>-]<+.--------------.[-] http://www.weirdnet.nl/