background Using the node-schedule scheduled task library, I wrote a script to automatically send emails at 7 am every day, and the email will get the date of the day. question The email was received at 3pm instead of 7am. I guess it was due to the time zone setting. Problem analysis and solutions After investigation, it was found that the node-schedule library does not support the selection of time zone, so it is sent according to the global standard time UTC by default. The time we usually pass in is CST, the Shanghai time zone in China, which is eight hours different. let j = schedule.scheduleJob('name',"0 7 * * *",'Asia/Shanghai', function () { console.log("Execute task"); getAllDataAndSendMail(); }); New Problem After changing the time, a new problem occurred. The time obtained in the email was yesterday's time, not today's time. Problem analysis and solutions After thinking about it, there are two places in the code to get the time, one is the time to send the email passed in by the scheduled task library, and the other is to get the current time in the script let today = new Date() Because I have printed today's log, check the log docker logs -f [containerID] # today:2021-11-12T23:00:00.106Z It was found that the email sent at 7 am was received today at 23:00 the previous day, which is also 8 hours different. Use the following command to enter the docker container to check the time $ docker exec -it [containerID] sh # After entering the container, the front will become# # Enter date to view the time date # Sat Nov 13 05:05:31 UTC 2021 It is indeed UTC global standard time, which means that the time of sending the email has indeed been changed back, but the time obtained when the code is executed is the current global standard time. docker cp /etc/localtime [containerID]:/etc/ Check the time in the container again as above and find that it has been changed back to CST. There should be no problem. This is the end of this article about the docker container time zone error problem. For more related docker time zone error content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Bootstrap 3.0 study notes grid system principle
>>: MySQL database index order by sorting detailed explanation
This script can satisfy the operations of startin...
Using abbreviations can help reduce the size of yo...
This tag is not part of HTML3.2 and is only suppo...
<br />In HTML language, you can automaticall...
Statement 1: <link rel="shortcut icon"...
Because we were going to build a website, in addi...
1. Install xshell6 2. Create a server connection ...
To create a flex container, simply add a display:...
Find the problem I recently migrated the storage ...
Think about it: Why should css be placed in the h...
This article shares the specific code of JavaScri...
Table of contents Install Tomcat Download Tomcat ...
Recently, there is a particularly abnormal busine...
How to solve the problem of forgetting the root p...
1 Introduction Apache Storm is a free, open sourc...