Fedora Linux Support Community & Resources Center
  #1  
Old 3rd June 2011, 07:46 AM
Jamwa Offline
Registered User
 
Join Date: Jan 2008
Location: Nairobi Kenya
Posts: 558
windows_xp_2003firefox
Cron script help

I am trying to write a cron job to get some regular backups. This is the command I hava in a file in the cron.d folder:

Code:
* * * * * root cd /var/www/html/backup; wget -c http://192.168.0.10/backup.`date +%Y-%m-%d`.tar.gz
But I get an error message,
Code:
/bin/bash: -c: line 0: bash unexpected EOF while looking for matching ``
I have even tried a different approach:

Code:
* * * * * root cd /var/www/html/backup; wget -c http://192.168.0.10/backup.$(date +%Y-%m-%d).tar.gz
To which I get
Code:
/bin/bash: -c: line 0: unexpected EOF while looking for matching `)'
The command runs just fine straight from the command line. What could I be doing wrong?

Last edited by Jamwa; 6th June 2011 at 06:48 AM.
Reply With Quote
  #2  
Old 3rd June 2011, 02:41 PM
PatMcLJr Offline
Registered User
 
Join Date: Apr 2005
Location: earth
Posts: 1,183
linuxopera
Re: Cron script help

I dunno,
maybe you could separate the command and the cron into a bash file and run that from the cron?

might be easier to debug

Pat Jr.
__________________
x--x--x
http://www.gnu.org/philosophy/free-sw.html
Freedom is never Free.
Pat Jr.
Reply With Quote
  #3  
Old 3rd June 2011, 10:41 PM
marko Offline
Registered User
 
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 6,031
linuxfirefox
Re: Cron script help

I got this to work:
Quote:
* * * * * root cd /var/www/html/backup; wget -c http://192.168.0.10/backup.`date +\%Y-\%m-\%d`.tar.gz
Note the back slashes before each %

actually I didn't get the username (root here) part to work, it would always take the username option as being part of the command and would not work. I don't get that since the example in the /etc/crontab file shows there is a username option. So I didn't actually use your command but I tried to approximate it with (again with no username between the last * and "cd" )

36 * * * * cd /home/mos/local; touch foocrontest.`date +\%Y-\%m-\%d`.tar.gz

Of course I don't have a remote server to use wget to get some file with a timestamp in the name so I cheated with using touch. You might still have parsing problems with that http URL that I didn't have

this successfully put a file in /home/mos/local -->
Quote:
ls -l local
-rw-rw-r--. 1 mos mos 0 Jun 3 17:36 foocrontest.2011-06-03.tar.gz

Last edited by marko; 3rd June 2011 at 10:47 PM.
Reply With Quote
  #4  
Old 6th June 2011, 06:46 AM
Jamwa Offline
Registered User
 
Join Date: Jan 2008
Location: Nairobi Kenya
Posts: 558
windows_xp_2003firefox
[solved] Re: Cron script help

marko thanks. Was not at all thinking about the back slashes. Your solution works ok.

PatMcLJr thanks but I tried that too but it was not successful
Reply With Quote
  #5  
Old 7th June 2011, 05:18 AM
marko Offline
Registered User
 
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 6,031
linuxfirefox
Re: [solved] Re: Cron script help

Quote:
Originally Posted by Jamwa View Post
marko thanks. Was not at all thinking about the back slashes. Your solution works ok.

PatMcLJr thanks but I tried that too but it was not successful
you could also simplify the cron command by doing this:
Quote:
* * * * * root wget -c -P /var/www/html/backup http://192.168.0.10/backup.`date +\%Y-\%m-\%d`.tar.gz
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
bug in apt cron script? Adrian_Hands Using Fedora 0 24th December 2007 08:25 PM
I need a script or cron job that does ... Wiles Using Fedora 1 13th September 2007 02:37 PM
help with a cron script Pulsorock Using Fedora 1 10th July 2007 07:24 AM
How to use screen cmd in a cron script? LouieLouie Using Fedora 6 8th June 2006 12:15 AM
Running a PHP script via cron blackarib Using Fedora 1 24th December 2005 01:18 AM


Current GMT-time: 11:18 (Monday, 01-09-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat