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

[cobalt-users] Re: 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«

mysqldump -uxxxxxx -pxxxxx --opt db > \
/home/dbbackups/sqldump_`date +%Y%m%d-%H%M`.sql

would give a filename of

sqldump_20030529-0122.sql

for May 29 2003 at 01:22 am.

'man date' for more info and options.

FYI -- be wary of including the -p switch on the commandline (I know 
there's no way around it for what you're doing but...) -- it will show the 
password to anyone who's running "top" or a "ps -ef" command etc.  If 
nobody else has shell on the box, you're ok.  Just make sure the user 
password for the db is NOT the same as a user password on your system. :)

-- 
Bruce Timberlake