cron job fails, but command in crontab succeeds when directly entered
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Leaving aside the kludgy nature of this for now, if i run the whole silly command directly, it works perfectly in just a few seconds. The DB is dumped, zipped, and thrown over the network to the target drive, where it lands safely.
When the cronjob runs, however, it chokes. I get this in the logs:
it eats it on the percentage sign. Now, inside the backtics, directly entered, it executes the command and substitutes the result as you'd expect. I have not yet been able to figure out a quoting scheme inside the crontab, however, that works. It dies there every time. i don't get it o_O.
TIA, and Halp!,
Rob
SOLUTION:
Assumed it was quoting, when i shoulda been escaping. Solution was to backslash the percent signs, thusly:
have you considered using a pre-existing script such as this one ? I find it works out great and would work around your current dilema as I could not see why it would not work.
have you considered using a pre-existing script such as this one ? I find it works out great and would work around your current dilema as I could not see why it would not work.
Regards
JKZfixme
Interesting script, but i think i end up with the same issue. The goal is a remote (Windows) server share, which i'm using smbclient to put the backup on.
The script you mention will run in crontab and make a mysql backup on the local disk. That part i have working; i'd still have to do something to move the backup to the remote server, which is my goal.
The problem is that crontab doesn't seem to like the %-signs in the date command; and since both my script and the one you mention timestamp the files, i'd need to include a way in the crontab of getting the current, timestamped file name.
Does anyone know what sort of quoting scheme i need to prevent cron from choking on the % arguments to the date command?
Solved: edited original post.
Last edited by rmunsch; 02-16-2009 at 05:44 PM.
Reason: solved
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.