Pop quiz (because I'm trying to solve this problem):How would you schedule a job to run at sunrise? Or at sunset?The problem, of course, being that "sunrise" and "sunset" are moving targets. Different each day by a few minutes.How would you solve this?#FreeBSD #Linux #cron #popquiz #programming

you are viewing a single comment's thread
view the rest of the comments
[–] 1 point 1 week ago (1 child)

@BastilleBSD metacpan.org/pod/DateTime::Eve (or similar) and then use that to generate oneshot cronjobs drop-in files w/a prefix of your choosing (for easy cleanup) in /etc/cron.d/, that fire off a command at the precise time per day based on timestamps from this? Cron runs every minute IIRC.Each week, clean up the old oneshot job file and generate next week's job file.Make sure to schedule the cleanup + regeneration task after the last sunset, but also before any summer/normal time changes.

  • source
  • hideshow 1 child comment
  • [–] 1 point 1 week ago

    @ermo @BastilleBSDYou can use the at(1) command to run something once, with no cleanup needed. Run a crontab entry after midnight to schedule two at commands for the day.Install at if it's not there. It's a small package.

  • source
  • parent