大网数据广告活动
服务器运维问答

What time zone is a cron job using?

· 52CE 我爱测

I'm guessing there's a difference between my PHP time and the server time. When I check the current time in PHP, it's showing that MST is being used. However, cron jobs aren't running at the correct time. How can I check to see w…

问题原文

原帖链接 · Edward · CC BY-SA 3.0

I'm guessing there's a difference between my PHP time and the server time.

When I check the current time in PHP, it's showing that MST is being used. However, cron jobs aren't running at the correct time.

How can I check to see what timezone the server itself is using, not what PHP is set to use?

已采纳解答

原帖链接 · imvikasmunjal · CC BY-SA 4.0

Cron job uses the server's define timezone (UTC by default) which you can check by typing the date command in terminal.

All countries timezones are defined in /usr/share/zoneinfo directory:

cd  /usr/share/zoneinfo/

When you cd into this directory you will see the name of different countries and their timezone.

Command to change server timezone.

sudo ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

If you live in America > LA you can change your time-zone using above command. Change the country and state according to your requirement.


Command to check the date and time:

 date

Set time and date from the command line:

date -s "19 APR 2012 11:14:00"

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-07-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。