Cron job in a different timezone

后端 未结 5 923
情深已故
情深已故 2020-12-31 05:27

Is there a way of setting up a cronjob for a specific timezone?

My shared hosting is in USA (Virginia) and I am in UK. If I set a cron job to be executed at 1600 hrs

5条回答
  •  不知归路
    2020-12-31 05:32

    You can use the CRON_TZ environment variable, excerpt from man 5 crontab on a CentOS 6 server:

    The CRON_TZ specifies the time zone specific for the cron table. User type into the chosen table times in the time of the specified time zone. The time into log is taken from local time zone, where is the daemon running.

    So if you add this at the top of your cron entry:

    CRON_TZ=Europe/London
    

    You should be good.

提交回复
热议问题