| |||||||||||
date function in shell cmds Posted by wilko (wilko), 22 December 2006 Hi There,Sorry for a basic question but I can't get this to work. I'm adding a line to my cronjobs to automate a mysqldump and this works: mysqldump -u root -pxxxx --opt rainweb > /usr/local/apache/htdocs/rweb2/bups/backup2.sql But, when I add in the date function I get "Illegal variable name": mysqldump -u root -pxxxx --opt rainweb > /usr/local/apache/htdocs/rweb2/bups/backup-$(date +%m%d%Y).sql I got this code from: http://www.phpbb.com/kb/article.php?article_id=123 I haven't tried this from CRON, just at the command line. I can't see what's wrong with my syntax - probably my head cold! Thanks and Merry Christmas. JW Posted by admin (Graham Ellis), 22 December 2006 I think you need to put the command that you run "within" in back quotes and not using the $(....) notation.Example: mysqldump -u root -pxxxx --opt rainweb > /usr/local/apache/htdocs/rweb2/bups/backup-`date +%m%d%Y`.sql Posted by wilko (wilko), 22 December 2006 That worked fine from the command line but CRON doesn't like it and returns "Syntax error: EOF in backquote substitution".I put it into an executable script, called that from CRON and that works fine. Thanks Graham This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |