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

Re: [cobalt-users] RaQ4 - datestamp filenames in script



Oh good. I was so excited to finally see a question I can answer and
then Bruce beat me to it. Then I looked close and thought at least I
can

still mention that depending  on your shell perhaps you may have to
use `date +"%Y%m%d"`

so since I'm writing in emacs let me open a shell and see if I'm
right.Oh well guess not - though I'm pretty sure in scripts, perhaps
scripts using sh I had to have the parameters in double quotes .  

war-admiral:/tmp $ ls fingal
ls: fingal: No such file or directory
war-admiral:/tmp $ touch fingal`date +%Y%m%d`
war-admiral:/tmp $ ls fingal
ls: fingal: No such file or directory
war-admiral:/tmp $ ls fin*
fingal20030131
war-admiral:/tmp $ touch fingal`date +"%Y%m%d%h"`
war-admiral:/tmp $ ls fin*
fingal20030131  fingal20030131Jan
war-admiral:/tmp $



On Thu, Jan 30, 2003 at 04:19:03PM -0800, Bruce Timberlake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> > I've got a small script running via cron to backup my MySQL
> > databases, it works but I'd like to amend this to create a new
> > backup file each day with the date in the filename.  What I'd like
> > to see is the date appended to the filename, i.e.
> > mysqldump30012003.tar.gz - the format of the date is not important
> > to me so long as it's recognisable.
> 
> 
> Just insert
> 
> `date +%Y%m%d`
> 
> wherever you want the date (YYYYMMDD is the order I showed; you can 
> change to suit) to appear.  For example:
> 
> tar cvfz $DESTINATION_DIR/mysqldump`date +%Y%m%d`.tar.gz
> 
> "man date" for other options besides %Y %m and %d...
> 
> - -- 
> Bruce Timberlake
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
> 
> iD8DBQE+OcD3vLA2hUZ9kgwRApcyAJ91JACkGBOLQCF7Wvq/cfSc/f11NgCZARhd
> lpjNTblEkbP5qQLLuM5WqqI=
> =F72e
> -----END PGP SIGNATURE-----
> 
> _____________________________________
> cobalt-users mailing list
> cobalt-users@xxxxxxxxxxxxxxx
> To subscribe/unsubscribe, or to SEARCH THE ARCHIVES, go to:
> http://list.cobalt.com/mailman/listinfo/cobalt-users

-- 
Josh Kuperman                       
josh@xxxxxxxxxxxxxxxxxx