Reputation: 387
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?
Upvotes: 12
Views: 22077
Reputation: 8711
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.
Upvotes: 20