here was the original question How to add a crontab job to crontab using a bash script?
#!/bin/bash
cronjob="* * * * * /path/to/command"
(crontab -u userhere -l; echo "$cronjob" ) | crontab -u userhere -
if I try to use command below bash is importing command and replacing (date +\%H_\%M-\%d.\%m.\%Y at the date and time of the import and I see imported command with fixed date stamp as..../mysql/21_18-27.05.2019_dbbackup.sql.gz
is there a way to keep date imported a formula?
cronjob="05 21 * * * /usr/bin/mysqldump -u mysqluserhere -pmysqlpassword DBname | gzip > /path/to/mysql/$(date +\%H_\%M-\%d.\%m.\%Y)_dbbackup.sql.gz" (crontab -u userhere -l; echo "$cronjob" ) | crontab -u userhere -
Many thanks