Re: CRON Script not working right.

2007-01-17 Thread Derek Ragona
Always use full pathnames to commands in cron scripts.  Change the lines to 
include the full paths for chown and chmod.


-Derek


At 09:31 PM 1/16/2007, Don O'Neil wrote:

Anybody have any clues why a shell script run from root's CRON would act
differently then when run directly from the command line?

Specifically, I have a script that looks for files on a NFS mount point and
copies them across and changes the ownership/perms.

Here's the gist of the script:

#!/bin/sh
TDIR=`date +%m%d%y%s`
mkdir /tmp/$TDIR
mv /source/* /tmp/$TDIR/
chown user:group /tmp/$TDIR/*
chmod 660 /tmp/$TDIR/*
mv /tmp/$TDIR/* /destination/

When run from roots CRON it does everything but the chmod correctly, which
is strange. When I run it from the command line as root it works fine as
expected.

I'm running 6.1-STABLE-200608.

Any clues?

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


CRON Script not working right.

2007-01-16 Thread Don O'Neil
Anybody have any clues why a shell script run from root's CRON would act
differently then when run directly from the command line?

Specifically, I have a script that looks for files on a NFS mount point and
copies them across and changes the ownership/perms.

Here's the gist of the script:

#!/bin/sh
TDIR=`date +%m%d%y%s`
mkdir /tmp/$TDIR
mv /source/* /tmp/$TDIR/
chown user:group /tmp/$TDIR/*
chmod 660 /tmp/$TDIR/*
mv /tmp/$TDIR/* /destination/

When run from roots CRON it does everything but the chmod correctly, which
is strange. When I run it from the command line as root it works fine as
expected.

I'm running 6.1-STABLE-200608.

Any clues?

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: CRON Script not working right.

2007-01-16 Thread Bill Campbell
On Tue, Jan 16, 2007, Don O'Neil wrote:
Anybody have any clues why a shell script run from root's CRON would act
differently then when run directly from the command line?

Most often this is because the environment in the cron job is
different, either missing variables or having variables that
aren't set to a reasonable value (e.g. TERM).

The way I usually figure something like this out is to dump the
envioronment from the cron job, then do the same thing from the
command line, then compare the two.

#!/bin/sh
# this is the cron job
env | sort  /tmp/env.cron
exit;

Now from the command line ``env | sort  /tmp/cron.cli''.

Now run something like ``diff -u /tmp/env.cron /tmp/cron.cli'' to
see what is different.

Bill
--
INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:(206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

When a place gets crowded enough to require ID's, social collapse is
not far away.  It is time to go elsewhere.  The best thing about space
travel is that it made it possible to go elsewhere.
-- Robert Heinlein
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]