Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
I have a Cron issue with my DNS323.
I have a NAS1 (a DNS323) that makes a backup to another NAS2 using a scheduled rscync script which starts around 04:05.
NAS1 has a user account "backup" which is able to ssh to NAS2 using no password. (rsync uses ssh under water so this is convenient).
The script is started via a cron job.
However, when the script is run via cron, I get this error message:
rsync: Failed to exec ssh: No such file or directory (2) rsync error: error in IPC code (code 14) at pipe.c(84) [sender=3.0.5] rsync: writefd_unbuffered failed to write 4 bytes [sender]: Broken pipe (32) rsync error: error in IPC code (code 14) at io.c(1509) [sender=3.0.5]
When I start the script as root, it all works fine.
Who understands what needs to be solved? Thanks very much!
The cron job entry is this:
root@DLINK:~# crontab -l 5 4 * * * /ffp/bin/snapshotMYBOOKWORLD.sh
This is the script:
root@DLINK:~# more /ffp/bin/snapshotMYBOOKWORLD.sh #!/bin/sh # Dit script is voor de MYBOOKWORLD # User backup van de Dlink kan zonder password ssh naar user fweijers op de Mybookworld. srcpath='/mnt/HD_a2/DOCUMENTEN /mnt/HD_a2/VIDEO/EIGEN* /mnt/HD_a2/FOTOS' datum=`date "+%Y%m%d_%H%M%S"` echo $datum >> /ffp/log/snapshotMYBOOKWORLD.log 2>&1 /ffp/bin/su -c "/ffp/bin/rsync -av $srcpath fweijers@192.168.178.100:/shares/internal/BACKUPNAS >> /ffp/log/snapshotMYBOOKWORLD.log 2>&1" backup datum=`date "+%Y%m%d_%H%M%S"` echo $datum >> /ffp/log/snapshotMYBOOKWORLD.log 2>&1 root@DLINK:~#
As you can see, I used a "su -c <command> <username>" construction.
My thought was that there lies the problem …I was thinking of PATH settings for user backup, but those PATH settings seem ok:
root@DLINK:~# echo $PATH /ffp/sbin:/usr/sbin:/sbin:/ffp/bin:/usr/bin:/bin root@DLINK:~# su - backup backup@DLINK:~$ echo $PATH /ffp/bin:/usr/bin:/bin backup@DLINK:~$ root@DLINK:~# ls -l /ffp/bin/ssh -rwxr-xr-x 1 root root 256336 May 19 2009 /ffp/bin/ssh root@DLINK:~# ls -l /ffp/bin/rsync -rwxr-xr-x 1 root root 373820 Mar 3 2009 /ffp/bin/rsync
How do I get the PATH settings correct for user "backup" when this script is started via Cron?
Cheers!
Last edited by fweijer71 (2013-01-09 01:35:05)
Offline
I am thinking the same thing, it's probably the path. Since cron is starting the shell in a non-interactive mode it initialization is a bit different and that may include setting path differently, although it's running with the same UID (user ID).
the su -c is redundant, I think.
add to the beginning of the script:
echo $PATH > /tmp/echo_path.txt
or
env > /tmp/echo_path.txt
and run it from crontab to see what the running environment is like.
You can add a line to the script to set PATH.
Offline
scaramanga is right. The cron environment is missing the path to the ffp binaries. So /ffp/bin/ssh is not found because /ffp/bin is not part of your path. This happens on some boxes (i dont know the reason. Firmware?)
The solution is to add
export PATH=/ffp/sbin:/ffp/bin:$PATH
as the second line in your script setting up the ffp environment.
Loose
Offline
And if this doesn't work try to add
export RSYNC_CONNECT_PROG='/ffp/bin/ssh'
or add the parameter
--rsh=/ffp/bin/ssh
to your rsync command.
Offline
Thanks a lot for your suggestions!
I will try the
export PATH=/ffp/sbin:/ffp/bin:$PATH
as the second line the script first. I will let you guys know soon if it solves the issue.
Some background about my configuration
I had the backup script from the start of this thread which backups Disk1 tot Disk2 in the DNS323 running for a long time.
Then I got another NAS in my home, which I started using as an "off-site backup".
I put it in my barn (you know, a thief will not rob both your house and you barn! I hope ) and had a copy backup script running almost the same rsync command as the Disk-copy, but this time from NAS1 to NAS2.
In order to do so, I had to make a ssh key-sharing solution because rsync uses ssh under water. The password-less ssh solution can be found here : http://www.linuxproblem.org/art_9.html
This setup worked fine, as long as the DNS323 doesn't reboot. When this happens, the file system is rebuild, wiping all the shared keys, making the password-less ssh stop, and thus failing the rsync command ...
So I created a user called 'backup', moved his homedir to Disk1
usermod -d /path/to/new/homedir/ username
and this way preventing the ssh keys from being wiped after a reboot.
This almost works ... first hopefully the suggested PATH-fix for crontab works.
After that, it appears that after a reboot the moved homedir of user backup cannot be found.... so I think I need to insert the usermod command in some script that is always run after a reboot of the DNS323.
Any suggestions for such a script?
Maybe someone can use my solution too ... It is very nice to have your precious date backed-up to another site on a daily basis!
Offline
Thanks Scaramanga and Loose Gravel!
The suggestion export PATH=/ffp/sbin:/ffp/bin:$PATH in the script works!
Any suggestion to have the home directory of a user moved, after a reboot?
This is the required command (somehow this is lost after a reboot ??
usermod -d /mnt/HD_a2/home/backup backup
Offline
fweijer71 wrote:
Thanks Scaramanga and Loose Gravel!
The suggestion export PATH=/ffp/sbin:/ffp/bin:$PATH in the script works!
Any suggestion to have the home directory of a user moved, after a reboot?
This is the required command (somehow this is lost after a reboot ??Code:
usermod -d /mnt/HD_a2/home/backup backup
There's a script that updates/stores it to flash: store-passwd.sh
Offline