0

i have a problem with crontab not running a script of mine at all. i have simplified the script down to a single line but it still won't run:

$ cat /etc/crontab
# /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 )
*/1 * * * * root /usr/share/test/script.sh                         
# don't forget the newline at the end (https://askubuntu.com/a/23337/12057):     


$ cat /usr/share/test/script.sh
#!/bin/bash                                                                     
echo "got here" > /tmp/test.txt

$ ls -l /usr/share/test/script.sh
-rwxr-xr-x 1 root root 951 May  8 08:59 /usr/share/test/script.sh

$ uname -a
Linux mypcname 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux

$ ps aux | grep cron
root      1111  0.0  0.0  22222  3333 ?        Ss   08:27   0:00 /usr/sbin/cron
me        4444  0.0  0.0   5555   666 pts/0    S+   09:06   0:00 grep --color=auto cron

as you can see the crontab should run script.sh once a minute and write to file /tmp/test.txt, however this file never appears. i have been reading through these possible reasons for cron not running, but so far none of them are applicable. i thought a fresh set of eyes might shed some light.

Community
  • 1
  • 1
mulllhausen
  • 4,225
  • 7
  • 49
  • 71

2 Answers2

0

Every minute is

* * * * *

not

*/1 * * * *

Related question: Using crontab to execute script every minute and another every 24 hours

Community
  • 1
  • 1
Lindlof
  • 2,152
  • 2
  • 17
  • 26
0

/var/log/syslog gave the clue to the answer:

May  8 08:50:01 mypcname /usr/sbin/cron[2222]: (*system*) WRONG FILE OWNER (/etc/crontab)
May  8 08:51:01 mypcname /usr/sbin/cron[2222]: (*system*) WRONG FILE OWNER (/etc/crontab)

$ ls -l /etc/crontab
lrwxrwxrwx 1 root root 24 Oct 12 2013 /etc/crontab -> /home/me/.crontab

$ ls -l ~/.crontab
-rw-r--r-- 1 root root 24 Oct 12 2013 /home/me/.crontab

i remember i did this when i installed the debian os since everything in my home dir is checked out from a subversion repository. i fixed up the issue like so:

$ sudo cp ~/.crontab /etc/crontab

and now it all works fine :)

mulllhausen
  • 4,225
  • 7
  • 49
  • 71