Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 6244  / 1 Year ago, mon, march 27, 2023, 2:54:50

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?


More From » 11.10

 Answers
3

/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...


[#39567] Monday, March 27, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
percol

Total Points: 493
Total Questions: 116
Total Answers: 107

Location: Taiwan
Member since Mon, Sep 6, 2021
3 Years ago
;