Cron error with using backquotes

后端 未结 2 1457
攒了一身酷
攒了一身酷 2021-01-11 21:36

The following works fine from command line

/usr/bin/mysqldump -uUser -pPass Db_name > /var/www/db_backup/db.`date +%Y%m%d%H%M`.sql 

but

2条回答
  •  旧时难觅i
    2021-01-11 22:04

    Put your one line script (as shown) into a proper script file and invoke that from cron:

    $ cat /usr/local/bin/db-backup
    #!/bin/sh
    /usr/bin/mysqldump -uUser -pPass Db_name > \
       /var/www/db_backup/db.`date +%Y%m%d%H%M`.sql 
    $ # use RHEL commands to add db-backup to your crontab
    

提交回复
热议问题