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.
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 05:44 PM.