I'm facing challenges in implementing a cron job for our daily check-in feature. Our goal is to send a push notification alarm daily to remind users to check in if they haven't already. The timing of these alarms should follow each user's local time zone. For example, Korean users should receive the push notification at 5 PM Korean time, while American users should receive it at 5 PM in their local (American) time zone.

How can I achieve this??

I've already implemented the business logic. It checks whether a user is targeted or not and sends the push alarm accordingly.

Is it possible to control the cron job time based on the user's time zone, or should I consider modifications at the user business logic level?

As a beginner developer, I apologize if I didn't provide enough information in my question.  Please leave your comments, and I'll try to rewrite it.

  • I don't think there is such a feature in cron (it will use the timezone of the system or the one you provided it, but not one for each user) so you probably need to make a job once an hour and check the timezone of the target yourself. It makes sense, because how will cron know which user you want to push? Commented Apr 29 at 6:31
  • @arielmarcovitch That's precisely what was bothering me. After talking with the client, they mentioned they could handle and control push notifications on their end as well. So, I've decided to leave it to the client. Thanks for your helpful answer. Commented Apr 29 at 7:11

1 Answer 1


I know of no cron implementation that will allow you to specify the timezone per entry. So, the solution here has to be more complex. Assuming that timezones differ from each other by no more than 15 minute intervals you will need to check four times an hour to see whether the local time is the appropriate value.

Knowing that the timezone labels are enumerated under /usr/share/zoneinfo you can use expressions like this:

TZ="Asia/Seoul" date +'%H:%M'    # "17:51"

Leading to a script such as this

if [ "$(TZ="Asia/Seoul" date +'%H:%M')" = '17:00' ]
    # South Korea 17:00
    : …
if [ "$(TZ="Europe/London" date +'%H:%M')" = '17:00' ]
    # UK 17:00
    : …
# etc.

You could encapsulate the TZ="Europe/London" date +'%H:%M' into a function but I don't think it would save much:

ztime() {
    local zone="$1" time="$2"
    [ "$(TZ="$zone" date +'%H:%M')" = "$time" ]

if ztime 'Europe/London' '17:00'
    # UK 17:00
    : …

With all these tests they will trigger only on during exact minute of matching. As with any trigger code you could create a more complex condition that was true only the first time the match succeeded on any given day.

You must log in to answer this question.

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