Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: aris on July 26, 2019, 09:25:10 PM
-
Hi all
I tried to using rsync to copy files from local network to tcl box, simple script
#!/bin/sh
rsync -avh root@192.168.3.3:/mnt/sda2/download/ /mnt/sda1/new &
run in mannualy using full comand on ssh works, using sh /path/to/files works
problem is it wont work on scheduled cron, tried to put it on /opt/bootlocal.sh still doesnt work. It wont run
I have other script on bootlocal.sh and it works just fine ..longer scripts
tcl version 7.2
the source folder is openwrt CC
rsync version 3.1.2 protocol version 31
so..where do I start ? what log should i paste here ?
thanks
-
Bootlocal runs as root, cron depends on whose cron. If you normally ran as user tc, you may have only stored the SSH details for that user. Further, if your network is slow, it may not be up when bootlocal runs.
Save all the output from rsync.
-
Hi Curaga, thanks for reply but I dont really understand it
If you normally ran as user tc, you may have only stored the SSH details for that user.
I can run as cron now..turn out my cron daemon is off before. I also tried on local machine on startup and its working to load on startup
rsync -avh /mnt/sda1/VID/src/ /mnt/sda1/VID/dest &
Tried smaller file to and add delay 45 seconds and add sudo but not working yet on startup#!/bin/sh
sleep 45
sudo rsync -avh root@192.168.3.3:/mnt/sda2/download/ /mnt/sda1/new &
The rsync is not run so no output, some bottom dmesg output random: nonblocking pool is initialized
r8169 0000:01:00.0: Direct firmware load for rtl_nic/rtl8168d-1.fw failed with error -2
r8169 0000:01:00.0: Falling back to user helper
r8169 0000:01:00.0 eth0: unable to load firmware patch rtl_nic/rtl8168d-1.fw (-11)
r8169 0000:01:00.0 eth0: link down
r8169 0000:01:00.0 eth0: link down
r8169 0000:01:00.0 eth0: link up
-
I found another thread that I think explain contain more explanation about running script from tc user http://forum.tinycorelinux.net/index.php?topic=19591.0 (http://forum.tinycorelinux.net/index.php?topic=19591.0)
so do I need to edit the /home/tc/.profile to run rsync in bootlocal but as tc ? not that I know which line to adjust
tc@box:~$ cat /home/tc/.profile
# ~/.profile: Executed by Bourne-compatible login SHells.
#
# Path to personal scripts and executables (~/.local/bin).
[ -d "$HOME/.local/bin" ] || mkdir -p "$HOME/.local/bin"
export PATH=$HOME/.local/bin:$PATH
ONDEMAND=/etc/sysconfig/tcedir/ondemand
[ -d "$ONDEMAND" ] && export PATH=$PATH:"$ONDEMAND"
# Environment variables and prompt for Ash SHell
# or Bash. Default is a classic prompt.
#
PS1='\u@\h:\w\$ '
PAGER='less -EM'
MANPAGER='less -isR'
EDITOR=vi
export PS1 PAGER FILEMGR EDITOR MANPAGER
export BACKUP=1
[ "`id -un`" = "`cat /etc/sysconfig/tcuser`" ] && echo "$BACKUP" | sudo tee /etc/sysconfig/backup >/dev/null 2>&1
export FLWM_TITLEBAR_COLOR="58:7D:AA"
if [ -f "$HOME/.ashrc" ]; then
export ENV="$HOME/.ashrc"
. "$HOME/.ashrc"
fi
TERMTYPE=`/usr/bin/tty`
[ ${TERMTYPE:5:3} == "tty" ] && (
[ ! -f /etc/sysconfig/Xserver ] ||
[ -f /etc/sysconfig/text ] ||
[ -e /tmp/.X11-unix/X0 ] ||
startx
)
-
Hi aris
Show us your bootlocal file.
-
Hi Rich
#!/bin/sh
# put other system startup commands here
/usr/local/etc/init.d/openssh start
#ntfs-3g /dev/sda3 /mnt/sda3
mount /mnt/sda4
mount /mnt/sda1
/usr/local/etc/init.d/samba start
#/usr/loca/etc/no-ip2.conf
#transmission-daemon -g /mnt/sda4/torrents/
#polipo -c /home/tc/.polipo/polipo.conf
#noip2
/opt/eth0.sh
/opt/eth0:0.sh
/usr/sbin/crond
/home/tc/cpdr33.sh &
/home/tc/cplocal.sh &
/home/tc/idle.sh &
/home/tc/ups.sh &
so the rsync from local network is cpdr33.sh, cp local is rsync inside tcl box,
eth0 is xxx1.200/24 eth0:0 is xxx3.200/24. the cpdr 33 copy from xxx3.3 to xxx3.200
-
Hi aris
Try changing this:
/usr/sbin/crond
to this:
/usr/sbin/crond -S -l 0 -L /home/$USER/crond.log
That's a lowercase L and zero after the -S. You can find out what these switches mean with this command:
crond --help
Now reboot and see if there is anything interesting in crond.log in your home directory.
I also read that commands given to cron to execute can not have a suffix, i.e. no .sh at the end.
-
Hi Rich ..sorry if my post is not clear enough. what I mean was
..cron is fine and its working... rsync on cron is also fine. what I intend to do now is by the time tcl box start it downloading files from local network.
But I still try your suggestion. Both cron (using .sh or with no .sh) is working fine.
so.. bootlocal file is
#!/bin/sh
# put other system startup commands here
/usr/local/etc/init.d/openssh start is working
/home/tc/cpdr33.sh & is not working
/home/tc/cplocal.sh & is working
/home/tc/idle.sh & is working
/home/tc/ups.sh & is working
cat /home/tc/cpdr33.sh
#!/bin/sh
#sleep 45
rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation &
so..may be I should run rsync on bootlocal as tc not root. If that so, how to do that ?
-
Hi aris
Try to see what /home/tc/cpdr33.sh is doing:
#!/bin/sh
echo -e "\n`date`\n >> /home/tc/rsync.log
ifconfig eth0:0 | grep -q "Bcast:" || echo "Network is down" >> /home/tc/rsync.log
rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
-
Hi Rich..still log no output
cat /home/tc/cpdr33.sh
#!/bin/sh
#sleep 45
echo -e "\n`date`\n >> /home/tc/rsync.log
ifconfig eth0:0 | grep -q "Bcast:" || echo "Network is down" >> /home/tc/rsync.log
root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
tc@box:~$ ls /home/tc/
cpdr33.sh cplocal.sh home/ idle.sh scripts/ shutdown_if_inactive ups.sh
tc@box:~$ uptime
09:50:38 up 4 min, 2 users, load average: 0.01, 0.04, 0.03
Mannualy its fine
rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
tc@box:~$ ls
cpdr33.sh home/ rsync.log shutdown_if_inactive
cplocal.sh idle.sh scripts/ ups.sh
tc@box:~$ cat rsync.log
receiving incremental file list
rsync: failed to set times on "/mnt/sda1/VID/MOO/#DELETE/.": Operation not permitted (1)
....
-
Hi aris
Hi Rich..still log no output ...
That suggests that /home/tc/cpdr33.sh is not being started from bootlocal.sh. Does this return anything:
ps aux | grep bootlocal
-
Hi aris
One more thought. Did you remember to make /home/tc/cpdr33.sh executable?
chmod 774 cpdr33.sh
-
That suggests that /home/tc/cpdr33.sh is not being started from bootlocal.sh. Does this return anything:
ps aux | grep bootlocal
nope
tc@box:~$ ps aux | grep bootlocal
2979 tc grep bootlocal
its 775 4 -rwxrwxr-x 1 tc staff 381 Jul 31 09:50 cpdr33.sh
So how do I start that rsync sh on bootlocal from tc user ? not from root, because bootlocal run as root ..if I understand correctly
-
Hi aris
I'm starting to run out of ideas. If you add a -x to the first line in your script like this:
#!/bin/sh -x
echo -e "\n`date`\n >> /home/tc/rsync.log
ifconfig eth0:0 | grep -q "Bcast:" || echo "Network is down" >> /home/tc/rsync.log
rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
and then run it:
./cpdr33.sh
what do you get?
-
sh /home/tc/cpdr33.sh
/home/tc/cpdr33.sh: line 9: syntax error: unterminated quoted string
and line 9 is
rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
run manually and its working rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
tc@box:~$ cat rsync.log
receiving incremental file list
./
test.txt
sent 46 bytes received 430 bytes 105.78 bytes/sec
total size is 317 speedup is 0.67
-
Hi aris
Sorry, my fault. Change this line from:
echo -e "\n`date`\n >> /home/tc/rsync.log
to:
echo -e "\n`date`\n" >> /home/tc/rsync.log
-
Hi Rich,
tried manually and its working
cat /home/tc/cpdr33.sh
#!/bin/sh -x
#copy files download an dr 3.3
ifconfig eth0:0 | grep -q "Bcast:" || echo "Network is down" >> /home/tc/rsync.log
rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
tc@box:~$ ./cpdr33.sh
tc@box:~$ cat rsync.log
Wed Jul 31 11:33:01 UTC 2019
receiving incremental file list
sent 20 bytes received 53 bytes 16.22 bytes/sec
Tried on reboot
tc@box:~$ cat /home/tc/rsync.log
Wed Jul 31 11:40:32 UTC 2019
Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.2]
-
So may be its because cron and manual .sh command is run by tc, as well as keypair generation, but bootlocal is run by root, so it doesnt know the key generated key by tc/ doesnt have the file (rsa file generate by tc).
-
Hi aris
Try changing this:
rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
to this:
sudo -u tc rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
-
Hi Rich
thats working perfectly...so its sudo -u...thank you very much
this is what I need
sudo -u tc rsync -avh -e "ssh -p 2112" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
tried to specify the key before but still Host key verification failed.
Doesnt matter..
rsync -avh -e "ssh -p 2112 -i /home/tc/id_rsa" root@192.168.3.3:/mnt/sda2/remote_source/ /mnt/sda1/local_destionation >> /home/tc/rsync.log 2>&1 &
again thank you..
-
Hi aris
You're welcome. Glad I could help.