LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 03-02-2013, 09:00 PM   #1
thund3rstruck
Member
 
Registered: Nov 2005
Location: East Coast, USA
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 346

Rep: Reputation: 38
Question svnadmin crontab issue


Just checked last year's source code backups and to my shock there weren't any! When I ssh'd into the subversion server I had 52 new mail messages!

Code:
/bin/sh: 1: Syntax error: end of file unexpected (expecting ")")
Looking at the crontab:
Code:
00 1 * * 1  svnadmin dump /home/svn/collection | gzip > /media/remote/Backup/svnserver01/$(date +%Y-%m-%dT%H:%M).backup.svn.gz
I ran the command directly in the terminal and it worked fine. What's wrong with running this command in a user crontab?
 
Old 03-02-2013, 11:45 PM   #2
eeekster
Member
 
Registered: Sep 2011
Posts: 157

Rep: Reputation: Disabled
Perhaps changing to this would do it:

Code:
00 1 * * 1  svnadmin dump /home/svn/collection | gzip > /media/remote/Backup/svnserver01/`date +%Y-%m-%dT%H:%M`.backup.svn.gz
 
Old 03-04-2013, 01:13 AM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995
Could be the fact that the default PATH in cron is minimal. Always recommended to specify absolute path to all cmds/files used or (better) put the whole thing in a script, call that and source/specify required PATH.
EG start by cd'ing into your dir, then copy PATH definition from your env.
 
Old 03-04-2013, 02:28 AM   #4
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,OpenBSD
Posts: 666
Blog Entries: 2

Rep: Reputation: 169Reputation: 169
I'm shocked it took longer than a week to notice this .. stuff that hasn't been tested should be assumed not to work.
 
Old 03-04-2013, 02:32 AM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,362

Rep: Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910
The real problem is that % signs need to be escaped, since they have a special meaning in crontab. The % signs in crontab will be changed to newline and everything after the first % sign is interpreted as standard input to the command. Therefore you crontab entry will result in:
Code:
00 1 * * 1  svnadmin dump /home/svn/collection | gzip > /media/remote/Backup/svnserver01/$(date +
Y-
m-
dT
H:
M).backup.svn.gz
and the parenthesis highlighted in red is responsible of the error. You should change the date command into:
Code:
date +\%Y\%m\%dT\%H:\%M
Hope this helps.
 
3 members found this post helpful.
Old 03-04-2013, 07:53 AM   #6
thund3rstruck
Member
 
Registered: Nov 2005
Location: East Coast, USA
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 346

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by linosaurusroot View Post
I'm shocked it took longer than a week to notice this .. stuff that hasn't been tested should be assumed not to work.
Ha... yea, it took 52 weeks; and even then I only noticed it because I was performing and annual backups audit. I guess it's a good thing that Subversion server didn't go down this year.
 
Old 03-04-2013, 08:07 AM   #7
thund3rstruck
Member
 
Registered: Nov 2005
Location: East Coast, USA
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 346

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by colucix View Post
You should change the date command into:
Code:
date +\%Y\%m\%dT\%H:\%M
Hope this helps.
Makes sense! I'll know tomorrow morning if it worked or not. Thanks!

----------UPDATE-----------

Yup, that works. I wonder why characters have to be escaped in a crontab definition but not in a standard bash script? Is it because cron doesn't use /bin/sh to run?

Last edited by thund3rstruck; 03-05-2013 at 08:51 AM. Reason: Update
 
  


Reply

Tags
cron, svn


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
One issue with Crontab abhitanshu Linux - Server 3 09-24-2012 02:34 PM
[SOLVED] Crontab issue pinga123 Linux - General 2 03-17-2011 01:56 AM
web svnadmin izghitu Linux - Software 0 04-23-2010 05:25 AM
[SOLVED] Crontab Issue shii_va Linux - Server 2 09-15-2009 11:30 AM
crontab issue adnanm Linux - Newbie 1 03-16-2007 02:28 AM


All times are GMT -5. The time now is 04:00 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration