Find the answer to your Linux question:
Results 1 to 2 of 2
I'm looking to set up a crontab that backs up a database every day, but I want the date to go in the filename. The command I'm trying to do ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Banned
    Join Date
    May 2006
    Posts
    8

    Inserting date into cron command


    I'm looking to set up a crontab that backs up a database every day, but I want the date to go in the filename.

    The command I'm trying to do is:
    Code:
    mysqldump --opt -Q -uuser -ppass dbname > dump.sql
    I want the contents to be dumped in dump-YYYYMMDD.sql though. How would I do this?

    Thanks in advance!

  2. #2
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    The Hot Humid South
    Posts
    602
    Look into the "date" command. You can have it output the date whatever way you want. If I'm not mistaken, to get it the way you want you would do:
    Code:
    `date +%Y%m%d`
    "Today you are freer than ever to do what you want, provided you can pay for it!" --Bad Religion

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •