I want to automate the crontab entry. Besides using crontab -e
I'm using crontab mycron
where the mycron contains the crontab content
In the bash script I have
tmpDir='/tmp'
myCron='mycron'
touch ${tmpDir}/${myCron}
if [ -f "${tmpDir}/${myCron}" ]; then
if "echo '#*/30 * * * * mysqldump -h <mysql_ip> -u <mysql_user> -p<mysql_passwd> --single-transaction --max_allowed_packet=1024m --databases <database_name>> /<path>/<to>/<file>/<file_name>_`date +\%d\%m\%y`.sql' >> ${tmpDir}/${myCron}" -a "echo '#33 1 * * * find /<path>/<to>/<file>/ -name <file_name>* -mtime +7 -exec rm -f '{}' \;' >> ${tmpDir}/${myCron}"
else
.....
fi
When executing the script I get the error:
..../<file_name>_210419.sql' >> /tmp/mycron: No such file or directory
I verified that I declared/assigned the various variables correctly. It seems inside the if "echo .... command the tmp and mycron file are not read correctly. I tried changing the quotes single/double, still didn't work. It probably is just a miss-type I'm not seeing. Thanks all four your help
Cheers, Roland
Aucun commentaire:
Enregistrer un commentaire