Koozali.org: home of the SME Server

Cron not working...

Offline basmistry

  • *
  • 19
  • +0/-0
Cron not working...
« on: August 21, 2008, 04:32:02 PM »
I've added a file called

bakk - to /etc/cron.d

The file contains

00 22 * * * root /sbin/bak1
00 23 * * * root /sbin/bak2

Then in /sbin I have bak1 & bak2 - with chmod 775

bak1
rsync -ar --delete /home/e-smith/files/ibays 192.168.1.100::backup

bak2
rsync -ar --delete /home/e-smith/files/ibays 192.168.1.101::backup

Thing is it does NOT work

I can run bak1 & bak2 manually and they execute

What am I doing wrong?



Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Cron not working...
« Reply #1 on: August 21, 2008, 05:46:20 PM »
hi

did you restart cron service?

if yes, have you read log files in /var/log? (/var/log/messages and /var/log/cron)

you'd find the reason why your scripts don't work

HTH
Ciao
Stefano

Offline basmistry

  • *
  • 19
  • +0/-0
Re: Cron not working...
« Reply #2 on: August 21, 2008, 06:15:24 PM »
To RESET cron I've setup a script

crontab -u root /etc/cron.d
/etc/init.d/crond restart

/var/log/con           says cron started
/var/log/messages   says cron startup succeded

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Cron not working...
« Reply #3 on: August 21, 2008, 11:32:14 PM »
bak1
rsync -ar --delete /home/e-smith/files/ibays 192.168.1.100::backup

bak2
rsync -ar --delete /home/e-smith/files/ibays 192.168.1.101::backup

Thing is it does NOT work

I can run bak1 & bak2 manually and they execute

What am I doing wrong?

One thing you are doing wrong is assuming that the execution environment will be the same when cron runs a command as when you do from the command line.

What happens if you do:

env - /sbin/bak1

from the command line?

Offline basmistry

  • *
  • 19
  • +0/-0
Re: Cron not working...
« Reply #4 on: August 22, 2008, 01:44:41 PM »
it just runs the bak1 script

I don't see any difference from typing

env - /sbin/bak1    or   just    bak1 at the prompt!

Nothing shown on screen and nothing in /var/log/messages

I don't understand - if the script executes crom command line why not from cron?

I've done this before but the server is 7.2 and hasn't been updated since installed last october.
It Rsync just fine to a remote site

I've also tried another script that has

ls -l /home/e-smith > home/dir.txt 

I've put this in the corn.hourly

This too does NOT seem to execute although I seen an entry ine /var/log/cron - run parts hourly



Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: Cron not working...
« Reply #5 on: August 22, 2008, 07:21:13 PM »
The cron environment normally is not aware of the paths to files unless you either code a PATH variable in your script or hardcode the path to all files you call in your script.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)