Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I get a bunch of error messages when I run crontab -e

Here are the error messages.

And here is my crontab file under `/usr/bin/':

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
30 *    * * *   root    rsync /home/dnaneet/Downloads/*.pdf /home/dnaneet/Downloads/pdfs/
#

I notice that the last task ('rsync') NEVER RUNS! Why is this happening? What did I do wrong?

Running Ubuntu 11.10/Bash. I have read this... Am I missing a shebang? And I don't know if my anacron jobs run.

Edit 1

In light of Masi's comment, I commented out lines 17 thru 25 of my crontab file with #.

Now when I run sudo crontab -e, all I get is:

/usr/bin/crontab: 11: 17: not found
/usr/bin/crontab: 12: 25: not found

(gedit:4301): Gtk-WARNING **: Attempting to store changes into `/root/.local/share/recently-used.xbel', but failed: Failed to create

file '/root/.local/share/recently-used.xbel.GOHVBW': No such file or directory

(gedit:4301): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: No such file or

directory

What in the world?

share|improve this question
    
@Masi as posted in the original text, the error messages are here: gist.github.com/2255983 .. (sorry if the hyperlink didn't work for you :P) –  drN Mar 30 '12 at 23:14
    
Ok, I was blind. Better to paste some of them to the body such that it is fast to see the problem if possible. –  Masi Mar 30 '12 at 23:15
    
Can you paste us the exact code which you are running, please, such as to dpaste. –  Masi Mar 31 '12 at 9:54

3 Answers 3

up vote 3 down vote accepted

/usr/bin/crontab is the command used for editing your user crontab. Looks like you've overwritten the crontab command with a crontab config file. The file you should be changing is /etc/crontab, not /usr/bin/crontab.

$ file /usr/bin/crontab
/usr/bin/crontab: setgid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
$ file /etc/crontab
/etc/crontab: ASCII English text

To fix, reinstall the cron package (sudo apt-get --reinstall install cron), then make your changes in /etc/crontab.

Your crontab entry looks quite correct though, just in the wrong file.

EDIT Given that your cronjob only copies files within your own homedir, you might as well have it run as your user. If you want to use the systemwide crontab, put the following line in /etc/crontab

30 *    * * *   dnaneet    rsync /home/dnaneet/Downloads/*.pdf /home/dnaneet/Downloads/pdfs/

Though I'd just use the personal crontab, which you edit using the crontab command. In this case the line should be:

30 * * * * rsync "$HOME/Downloads"/*.pdf "$HOME/Downloads/pdfs/"

After you have done either change, that rsync command should run once an hour, at 00:30, 01:30, 02:30, 03:30, etc...

share|improve this answer
    
Thanks for your answer. I reinstalled cron with apt-get as you recommended. However, after editing the crontab file crontab -e, I checked what it looked like under /etc/crontab and I see that my edit wasn't made. Is this the wrong place I am looking for the crontab I just edited? –  drN Mar 31 '12 at 15:11
    
@DNA Different crontabs. crontab -e edits your user's personal crontab. /etc/crontab is a completely separate crontab file you can edit directly. Since it is not limited to a single user, it has a sixth field (which you don't have with crontab -e) telling which user the job should run as (in your case you chose root). –  geirha Mar 31 '12 at 15:42
1  
@DNA The personal crontabs gets stored under /var/spool/cron/crontabs/. Do not edit those manually though, only modify them through the crontab command (e.g. with crontab -e) –  geirha Mar 31 '12 at 15:44
    
Ok. that makes sense. I'll check to see in a few minutes how well my crontab edit works! Thanks all of you! –  drN Mar 31 '12 at 17:16

The format of your crontab file seems to be wrong. You are using spaces instead of tabs there. Please, see this.

Please, run the trivial example crontab file and see what happens. Then apply the similar changes about the format one by one to your file.

What is the command test? Do you have it in your PATH?

share|improve this answer
    
Wow! I didn't realize that! Thanks for the edit! However, sudo crontab -e still gives me the same errors! :( –  drN Mar 30 '12 at 23:18
    
@DNA Show me what you run and what you get. Paste it to dpaste for instance. –  Masi Mar 30 '12 at 23:20
    
You are right, test doesn't exist. I was being an idiot there and now I have commented lines 17 thru 52 out with the # symbol . I have made an edit in my question to include the result of running this. –  drN Mar 30 '12 at 23:27
1  
@DNA It makes no sense to have /etc or /etc/crontab in PATH, so undo that change. You do not need to change PATH at all for this. All you need to do is add that rsync line to /etc/crontab, then it will be run once an hour by crond. –  geirha Mar 31 '12 at 8:45
1  
Spaces are perfectly acceptable in crontabs; you don't have to use tabs. –  Scott Severance Mar 31 '12 at 18:42

Not sure if that's the problem, but maybe you want to try putting the * in quote for rsync:

rsync /home/dnaneet/Downloads/'*.pdf' /home/dnaneet/Downloads/pdfs/

share|improve this answer
    
But rsync doesn't need quotes to work.. –  drN Mar 31 '12 at 3:52
    
rsync didn't need the quote. Thought I'd let you know. Thanks for trying! :) –  drN Mar 31 '12 at 20:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.