Cheatsheet: dynamic date value in shell scripts

using a variable – easier to read in scripts:
NOW=$(date +"%Y%m%d%H%M%S")
echo "bar" > "$NOW"foobar.txt

one-line, equivalent to above:
echo "bar" > $(date +"%Y%m%d%H%M%S")foobar.txt

alternate single-line format:
echo "bar" >> $(date "+myfile%Y%m%d.txt")

man strftime to see formatting values

hardware time on cloud server

In order to set the time correctly (timezone, ntp time sync, etc.) on a cloud server, you need to indicate that the system does not support hardware time. I’m not entirely sure how to do this manually, at least not anymore, but if you are using webmin (which I do often use for expediency but only start it up when needed) – here is what you need to set:

Webmin>Hardware>System Time>Module Config>System Configuration>System supports hardware time

set to: no

For time server sync, I use:

0.pool.ntp.org

and sync when webmin starts and turn the schedule on for once a day (may want to set more often if your apps are time critical and/or are syncing data based on timestamp, e.g., svn server).