I have a bash script that I use to backup the contents of a SSD every day however I use the following command in the script to name the file
zip -r ssd-$(date "+%b_%d_%Y").zip ../ssd
It already appends the month, day, and year to the file name however how can I modify that to also append the timestamp of the server onto the file name as well?
Add _%H_%M_%S
into the date-format string as well. For example, date +%b_%d_%Y_%H_%M_%S
produces a string like
Oct_07_2012_17_57_36
. For a shorter string, consider format %s; eg, date +%s
produces a string like 1349654346, the number of seconds since 1970-01-01 00:00:00 UTC.
Does the following do what you need?
date "+%b_%d_%Y_%H.%M.%S"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With