2

If I run crontab -e and add a cronjob 4 5 * * * "echo hi", the job will run at 5:04 of what timezone? Let's say the laptop displays time in PST in the top menu bar and sudo systemsetup -gettimezone is Time Zone: America/Los_Angeles.

I tried running a test job to find the answer, but the job didn't run when I expected in both UTC and PST. Probably a simple misconfiguration, but I'd like to confirm what timezone I should expect first.

2
  • @Allan I ran the mail command later and found out that the syntax was misconfigured, as I thought. If you go into a mail it says the time and timezone, which matches the system time. So feel free to post that as the answer and I'll accept it :)
    – Almenon
    Commented Jul 18, 2023 at 18:56
  • 1
    Glad you got it sorted!
    – Allan
    Commented Jul 18, 2023 at 19:21

1 Answer 1

1

cron will run at it’s scheduled time based on the system time regardless of timezone. For instance, your scheduled job will run at 5:04am system time. If you’re in LA at 2am and you head to Miami where the time adjusts to 5am local (assuming you got a ride with The Flash), your job will run at 5:04am (Miami time).

The job, however, will not run if the computer is asleep; it will just run at it’s next scheduled event time. I also suggest looking at utilizing launchd as cron was supposedly deprecated by Apple in it’s favor.

1

You must log in to answer this question.

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