Cron工作在不同的时区 [英] Cron job in a different timezone

查看:379
本文介绍了Cron工作在不同的时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为特定时区设置cronjob?



我的共享主机位于美国(弗吉尼亚州),我在英国。如果我设置一个cron作业,每星期五在1600小时执行,那么它将在1600年在弗吉尼亚州执行。



我想知道我是否可以设置我的cronjob这样的方式,它了解哪个时区选择。我不太担心夏令时的区别。



我问过我的共享托管服务提供商,他们说我应该能够设置一些cron ini文件中的时区,但我找不到。

解决方案

我认为你应该检查

  / etc / default / cron 

类型

  Crontab cronfile 


b $ b

,您应该会找到

  TZ = UTC 
pre>

这应该更改(例如America / New_York)。第二种方式在cron中设置示例

  5 2 3 * * TZ =America / New_York/ do / command& / dev / null 2>& 1 


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 every friday, then it will execute when its 1600 in Virginia.

I was wondering if I can setup my cronjob in such a way that it understands which timezone to pick. I am not too worried about daylight saving difference.

I have asked my shared hosting providers about it and they said I should be able to set the timezone in some cron ini files, but I could not find any.

解决方案

I think that you should check

/etc/default/cron

or just type

Crontab cronfile

and you should find

TZ=UTC

This should be changed (for example America/New_York). Second way is set in cron example

5 2 3 * * TZ="America/New_York" /do/command > /dev/null 2>&1

这篇关于Cron工作在不同的时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆