Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
I am new to Linux and scripting. I have a DNS-323 w/funplug 0.5
I created a script that backs up folders on the hard drive to a USB drive. It works running manually but fails when I try to run the script through cron.
12 3 * * 1-5 /mnt/HD_a2/scripts/backup_dlink00.sh
Because the USB drive might connect to any /dev/sxx (depending on what else has been mounted at the time) I wanted to look for a specific drive at backup time and see where it was connected and use that information to mount the drive. I have labeled my backup drives "DLINKBKUP00" and use:
DEVNODE=$(blkid -t LABEL=DLINKBKUP00 | awk -F: '{print $1}')
to see if the disk is there and take the connection part I need for mounting the drive.
The problem is that blkid returns an error 127 (-1) when the script is run from cron. The script works just fine from the command line.
Attached is the entire script...a little help would be great!
Offline
I found the path to be an issue when using cron.
For example when calling awk or grep I had to either add the path to the script, or use CMDGREP=/mnt/HD_a2/ffp/bin/grep" then use the command by calling $CMDGREP instead.. obviously same for awk.
Last edited by crs2027 (2010-02-26 18:40:41)
Offline
I don't even think it is getting to the 'awk' command. I tried a simple script:
#!/bin/sh
# Author: Stu Schechter
NOW=$(date +"%b-%d-%y")
LOGFILE="/mnt/HD_a2/scripts/backuplog-$NOW.log"
date >> $LOGFILE
blkid >> $LOGFILE
exit 0
the DATE showed up in the logfile but blkid showed nothing.
Can cron have trouble finding/using 'blkid'?
Offline
The PATH might be set differently when running in cron. You can verify this by echoing $PATH to a file.
A simple workarond as described above, is to always use fullpath to all commands.
/ffp/bin/date
/ffp/sbin/blkid
/ffp/bin/awk
etc...
Another is to set the PATH correctly.
Last edited by bjby (2010-02-28 19:36:18)
Offline
That was it. Specifying full paths did the trick...thanks for helping a newbie!
I looked at $PATH and it shows:
/ffp/sbin:/ffp/bin:other paths...
These are the correct paths so why does cron not seem to get it?
Offline
This is why, (I think, might be wrong)
When you login the /ffp/etc/profile script is run, it sets the path variable.
I the environment cron i running this profile script has not been executed, thereby the path variable is different.
Offline