I recently lost configuration of one of my IDEs (deleted it myself, I am very smart). I had a backup but it was a few months old. I have a script to backup all my config and push it to GitHub. I was looking into a way to run a script every week to back up everything automatically but launchd / cron need a specific time to run. My laptop might not be running at that time but I do boot up my laptop every weekend at least once.

Is there a way to configure launchd / cron to run on a weekend at any time to back up my configuration?


To make it clear, the question is not a duplicate of the one posted in the comments. The other question talks about running a script "10 minutes after 2 am every weekday only", not anytime possible on a weekend. Only once per weekend.

  • 1
  • Not a duplicate. I don't want a script to run at a specific time, just anytime on a weekend. – Sourabh Jul 21 '18 at 15:13
  • 1
    There's no random time that can be given as an interval. However, if it doesn't run at a particular schedule, it will do so the next time it's run. – Allan Jul 21 '18 at 15:52
  • "if it doesn't run at a particular schedule, it will do so the next time it's run." didn't get that. You mean if a cron of 4:20 Sunday didn't run because laptop was off then it'll run whenever laptop is turned on, on a sunday? – Sourabh Jul 21 '18 at 19:49
  • Yes. It will run the very next time. – Allan Jul 21 '18 at 19:54

Set your computer to power on or wake from sleep on a specific day and time (Energy Saver preferences), then run your script though launchd or cron within that time frame.

  • It's a laptop (MacBook). Will the EnergySaver work even if the lid is down? – Sourabh Jul 21 '18 at 15:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .