Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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:
    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
    The Hot Humid South
    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:
    `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