Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 6th January 2013, 20:42
fweijers fweijers is offline
Junior Member
Join Date: Aug 2009
Posts: 13
Thanks: 0
Thanked 3 Times in 3 Posts
Default Script sun as other user than root doesn't via CRON

I have a NAS1 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

# 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@ >> /ffp/log/snapshotMYBOOKWORLD.log 2>&1" backup

datum=`date "+%Y%m%d_%H%M%S"` 
echo $datum >> /ffp/log/snapshotMYBOOKWORLD.log 2>&1
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
root@DLINK:~# su - backup
backup@DLINK:~$ echo $PATH

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

Last edited by fweijers; 8th January 2013 at 12:41. Reason: improved markup
Reply With Quote
The Following User Says Thank You to fweijers For This Useful Post:
aangelatexaxda9431 (13th February 2013)
Sponsored Links


cron, rsync, ssh, user

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
apache log issues abubin General 13 1st August 2010 18:47
automatic webmail link admins Installation/Configuration 16 22nd June 2009 17:42
messed up apache2-php5 installation klonos HOWTO-Related Questions 2 25th January 2009 00:12
monit howto Jamesk5 HOWTO-Related Questions 11 5th August 2008 16:10
cannot connect to ispconfig guidovanh Installation/Configuration 22 3rd March 2006 20:52

All times are GMT +2. The time now is 09:34.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.