Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 为什么CRON_TZ设置在/etc/crontab不起作用?_Bash_Shell_Cron_Timezone - Fatal编程技术网

Bash 为什么CRON_TZ设置在/etc/crontab不起作用?

Bash 为什么CRON_TZ设置在/etc/crontab不起作用?,bash,shell,cron,timezone,Bash,Shell,Cron,Timezone,在/etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root CRON_TZ=Asia/Tokyo # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .----------

/etc/crontab

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
CRON_TZ=Asia/Tokyo

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
在一个用户下创建了一个cron作业作为

crontab -e
0 1 * * * echo 'task' > /tmp/task

它在东京1点没有运行。但是在9小时之前。是UTC。为什么
/etc/crontab
不能在全球范围内工作?

根据我在谷歌搜索时发现的情况,它在发行版和版本上差异很大,但您可能需要设置一个额外的
TZ
变量,或者更新
/etc/localtime
@SomethingDark
/etc/localtime
中的时区,它是一个二进制文件。我可以将
TZ
添加到
/etc/crontab