LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-08-2008, 04:04 PM   #1
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 317

Rep: Reputation: 30
Crontab not working


Code:
5 6 * * sat mutt -s "BIYG backup `date +%m-%d-%y`" -n -F /dev/null -a /home/xxx/backup/biyg_backup_`date +%y%m%d`.tgz xxx@gmail.com < /dev/null
Gives me an error:
Quote:
U 2 root@xxx.org Sat Sep 27 06:05 25/952 "Cron <zeno@vps> mutt -s "BIYG backup `date +"
Code:
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
Any idea why? That mutt line works just fine in /bin/sh
 
Old 10-08-2008, 04:12 PM   #2
Woodypecker
Member
 
Registered: Mar 2006
Location: Austria
Distribution: Mandriva/Debian
Posts: 104

Rep: Reputation: 17
Obviously, if you copied your line correctly, there is a missing backtick.
Backticks mean the same as old "eval", actually yours was intended to add the
result of a formatted date (but that's malformed as well) to the subject.
As an example, date "+%d.%m.%Y" gives the current date in day.month.year notification.
Your line most likely should look more like mutt -s "BIYG backup `date +"%y-%m-%d"`
 
Old 10-08-2008, 04:23 PM   #3
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 317

Original Poster
Rep: Reputation: 30
My code had worked in sh as so:
Code:
sh-3.2$  mutt -s "BIYG backup `date +%m-%d-%y`" -n -F /dev/null -a /home/xxx/backup/biyg_backup_`date +%y%m%d`.tgz xxx@gmail.com < /dev/null
sh-3.2$
And your way works too:
Code:
sh-3.2$  mutt -s "BIYG backup `date +"%m-%d-%y"`" -n -F /dev/null -a /home/xxx/backup/biyg_backup_`date +%y%m%d`.tgz xxx@gmail.com < /dev/null
sh-3.2$
So my way didn't work in crontab because it handles backticks differently?
 
Old 10-08-2008, 05:10 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
From man 5 crontab:
Quote:
Percent-signs (%) in the command, unless escaped with backslash (\),
will be changed into newline characters, and all data after the first % will
be sent to the command as standard input.
this is the meaning of the error message: the string "mutt -s "BIYG backup `date +" is interpreted as the command, the rest of the line as standard input. Obviously the shell complains about an unexpected end of file, due to the first backtick left unclosed.
 
Old 10-08-2008, 06:55 PM   #5
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 317

Original Poster
Rep: Reputation: 30
Ah, I should have just RTFM.

Anyway, didn't need to fix the backticks and it worked just fine when escaping the percent signs.
 
  


Reply


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
crontab not working ankitsagwekar Red Hat 1 08-08-2008 06:45 AM
crontab not working mahmoud Linux - Newbie 16 07-11-2008 01:46 PM
Crontab Not working appropriate? roclok Linux - Software 9 06-16-2006 12:34 AM
crontab not working durgap Linux - General 6 09-01-2005 03:38 PM
crontab nor working navaladi Mandriva 11 01-17-2005 07:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:44 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration