[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] Timestamp on filename?



> Is it possible to add a timestamp to the file name?
> I have a cron job making a sqldump like this:
> mysqldump -uxxxxxx -pxxxxx --opt db > /home/dbbackups/sqldump.sql
>
> I would like to have the file named like this »sqldump_TIMESTAMP.sql«
>

i use this

#!/bin/sh
date=`date +%H%M`
mysqldump -uxxxxxx -pxxxxx --opt db > /home/dbbackups/sqldump_$date.sql

use man date to see the options for the date command. this script has date
in the format HHMM where HH is the current hour and MM is the current
minute.

andy