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.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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!,
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.
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 06:44 PM.