I can execute shell script from CLI but failed to do via cron
I created the following shell to mount/umount network-shared volume.
1> I succeed to execute the shell script to mount/umount my win2003`s filesystem.
2> I tried to enable the shell execution in crontab as follows.
0-30/5 4 * * * sh /net-vol/mount_shell &
3> /var/log/cron tolds me that the crontab has been enabled successfully. But the shell execution seems not to be executed.
I must add the ". /etc/profile" in the head of the shell script so that
mount_shell can mount/umount normally via cron.
4> I think /etc/profile should be executed during system boot. And the
shell script under crontab should inherit all environments viariables.
And I can manually execute the shell without the line of ". /etc/profile". Pls help
======= The last two lines of /etc/profile ===========
. $ENV/`hostname`/env01
. $ENV/`hostname`/env02
================ mount_shell content ====================
#!/bin/sh
### Mount files to /mnt/interchk ####
# . /etc/profile ==> Now, I must add the line for shell execution via crontab.
. $ENV/`hostname`/current-time.sh
mount -t cifs -o credentials=$PASSFILE //win2003/InterChk /mnt/interchk"
if [ $? -eq 0 ] ; then
echo "$CURRENT_TIME $HOSTNAME $PROC: mount /mnt/interchk -- Success " >> "$LOGFILE"
else
echo "$CURRENT_TIME $HOSTNAME $PROC: mount /mnt/interchk -- Failure " >> "$LOGFILE"
exit
fi
....
....
### Umount /mnt/interchk ###
sleep 60
. $ENV/`hostname`/current-time.sh
umount /mnt/interchk
if [ $? -eq 0 ] ; then
echo "$CURRENT_TIME $HOSTNAME $PROC: umount /mnt/interchk -- Success " >> "$LOGFILE"
else
echo "$CURRENT_TIME $HOSTNAME $PROC: umount /mnt/interchk -- Failure " >> "$LOGFILE"
fi
Last edited by UltraSoul; 06-24-2008 at 01:06 AM.
|