Results 1 to 4 of 4
Hello,
I am having a promblem with cron in Fedora 8.
I am trying to make cron do a job (the scheduling is not the issue) which tars a users ...
- 03-04-2009 #1Just Joined!
- Join Date
- Mar 2009
- Posts
- 2
Cron problems
Hello,
I am having a promblem with cron in Fedora 8.
I am trying to make cron do a job (the scheduling is not the issue) which tars a users home folder and any file associated with that user in the /var folder.
I keep getting error mail sent and I do not know where I am going wrong. I tried the command out in BASH shell and it worked. I even made cron use BASH insted of /bin/sh...
Here is my code I put into crontab -e:
What I think is happening here is, is tars /home/arnold with the name "arnold(current date).tar" and if that is successful is finds all files with the owner arnold in the /var and appends them to the archive...Code:SHELL=/bin/bash 15 4 25 * * tar -cvf "arnold-`date +%Y-%m-%d`.tar" /home/arnold && tar -rvf arnold-'date +%Y-%m-%d'.tar `find /var -user arnold`
and this is what cron sends to /var/spool/mail/root
I don't know why cron sees an EOF... It is eluding me... I'm sure it is the date command but I don't know any other to allow to input the current date into the filename (I need to have the date in the filename).Code:From root@localhost.localdomain Wed Mar 4 08:59:01 2009 Return-Path: <root@localhost.localdomain> Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.2/8.14.2) with ESMTP id n24Dx1qn002941 for <root@localhost.localdomain>; Wed, 4 Mar 2009 08:59:01 -0500 Received: (from root@localhost) by localhost.localdomain (8.14.2/8.14.2/Submit) id n24Dx1HQ002940; Wed, 4 Mar 2009 08:59:01 -0500 Date: Wed, 4 Mar 2009 08:59:01 -0500 Message-Id: <200903041359.n24Dx1HQ002940@localhost.localdomain> From: root@localhost.localdomain (Cron Daemon) To: root@localhost.localdomain Subject: Cron <root@localhost> tar -cvf /var/local/backup "arnold'date + Content-Type: text/plain; charset=UTF-8 Auto-Submitted: auto-generated X-Cron-Env: <SHELL=/bin/bash> X-Cron-Env: <HOME=/root> X-Cron-Env: <PATH=/usr/bin:/bin> X-Cron-Env: <LOGNAME=root> X-Cron-Env: <USER=root> /bin/bash: -c: line 0: unexpected EOF while looking for matching `" ' /bin/bash: -c: line 1: syntax error: unexpected end of file
I know I could use the --backup option for tar but I want to get it working before that. I am sure it is the date command that is screwing things up.
Any help would be appreciated!
- 03-04-2009 #2Just Joined!
- Join Date
- Feb 2009
- Posts
- 25
hmmm... looks like a typo
15 4 25 * * tar -cvf "arnold-`date +%Y-%m-%d`.tar" /home/arnold && tar -rvf arnold-'date +%Y-%m-%d'.tar `find /var -user arnold`
the escape sequence character is not correct, tar -rvf arnold-`date +%Y-%m-%d` should fix this
- 03-04-2009 #3Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
The most common issue with cron jobs is the minimal $PATH. I see above the $PATH is PATH=/usr/bin:/bin
I'd check the location of tar,date and find on your system to make sure they are somewhere cron can find them, perhaps prefixing each command with its own full path.
- 03-05-2009 #4Just Joined!
- Join Date
- Mar 2009
- Posts
- 2
no the escape characters i wrote were wrong, I meant to use ` instead of '
I figured it out. The % sign in cron makes a carrage return I needed to put a backslash infront of them to make it not see it as thus.
Thanks anyway.


Reply With Quote