Crontab显示不同的时间,手动运行时的Shell脚本显示不同的时间戳记

问题描述 投票:0回答:1
#!/bin/sh

string1=$(date +"%T")
string2=$(date -r merchant.xml +"%T")
StartDate=$(date -d "$string1" +"%s")
FinalDate=$(date -d "$string2" +"%s")
echo Since,  $(date -d  "0 $StartDate sec - $FinalDate sec" +"%H:%M") HOURS, mail has not been updated | mail -s "Merchant File Staleness" [email protected]

这是我的shell脚本名称hp.sh,输出为

Since, 00:55 HOURS, mail has not been updated. 

crontab是

0 * * * * /tmp/hp.sh 

crontab的输出为

Since, 07:04 HOURS, mail has not been updated.

两者的输出是不同的。我每小时需要使用crontab输出我的shell脚本。

linux shell unix unix-timestamp
1个回答
0
投票

检查系统和用户定义的TZ变量-cron乐于接受在那里设置的内容,即使它与系统设置不同。

© www.soinside.com 2019 - 2024. All rights reserved.