Try escaping the percent signs with backslashes:
They are special characters and I think maybe sh is breaking on them.Code:... /path/to/backup/dbbackup_`date +\%b\%d`.sql
Try escaping the percent signs with backslashes:
They are special characters and I think maybe sh is breaking on them.Code:... /path/to/backup/dbbackup_`date +\%b\%d`.sql
I have been using gawk to help name compressed versions of my testing server Harry's MySQL dump file called imaginatively enough "SqlDump.sql" The shell script looks like this:
# Small script to compress the dump file and add DOW
tar -cvpzf Harry`date |gawk '{print$1}'`Bk.tar.tgz SqlDump.sql
echo now its all squished up
The output is HarrySunBk.tar.tgz
This gives a rolling 7 days available on my test server for rolling back. I also use gawk (on my backup server)to rename files I pull daily to the backup server. On my testing server I run the same script but without the gawk part to generate the target for this pull.
You may insert $1$2$3$4$5 or parts therof to get the desired date parts you want.
You will need to install gawk using #apt-get install gawk
I hope this is of some use
I am trying to set up cron to run a script. I thought I had done everything right but the script didnt autorun...soooo...I tried this as a benchmark..just for cron to launch pidgin every minute...well..it doesnt launch pidgin either...what am I doing wrong?
gempak@xxxxxxx:/data/ldm/gempak/tasksched$ crontab -l
* * * * * pidgin
Probably it's the same issue as one that people were having earlier in the thread: you need to put the FULL path of any program you want to run. On my machine, anyway, pidgin lives in /usr/bin/ (you can find out where it lives by doing 'which pidgin' at a terminal), so the line you want would be
Hope this helps.Code:* * * * * /usr/bin/pidgin
Disregard below. I hadn't scrolled to page 9 of the thread yet. Nevermind.
Hi,
I just ran into this and found this thread googling for the answer.
Looks like this will be your solution, but I haven't tried it myself yet:
http://www.mail-archive.com/freebsd-.../msg22297.html
Summing it up:
Crontab treats '%' characters specially --- see crontab(5). It will
automatically replace a '%' character with a newline, as a method of
being able to include multiline shell input into the crontab file.
To get a literal '%', type '\%'
Good luck!
René
Last edited by Iturbide; October 9th, 2008 at 10:25 AM. Reason: Correction
For those new to Ubuntu, like me... if you find that "crontab -e" give you a missing command error, then you need to install the package cron
sudo apt-get install cron
In the hopes that this will save someone the time I just wasted, also be very sure that your crontab line is ended with a carriage return. If you don't your command will not run, you may not get any error message, and frowning may ensue.
correct:
* * * * * /usr/bin/touch /tmp/this.file
<EOF>
incorrect:
* * * * * /usr/bin/touch /tmp/this.file<EOF>
"frowning may ensue"
I know the feeling.
About your post:
Carriage Return (13) is Mac. Line Feed (10) is Unix/Linux.
I always just say Line Break or New Line when referring to creating a line - that avoids confusion.
Just wondering if you could add instructions on how to modify the system wide crontab file. This capability may want to be added -- for example to periodically update the dyndns address, or something similar.
That would be great, since the process is slightly different than the user crontab procedure.
Bookmarks