WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: rsync wont start on schedule and boolocal  (Read 4184 times)

Offline aris

  • Newbie
  • *
  • Posts: 49
rsync wont start on schedule and boolocal
« 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
Code: [Select]
#!/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

Online curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
Re: rsync wont start on schedule and boolocal
« Reply #1 on: July 26, 2019, 10:52:28 PM »
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.
The only barriers that can stop you are the ones you create yourself.

Offline aris

  • Newbie
  • *
  • Posts: 49
Re: rsync wont start on schedule and boolocal
« Reply #2 on: July 27, 2019, 01:27:41 AM »
Hi Curaga, thanks for reply but I dont really understand it
Quote
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
Code: [Select]
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
Code: [Select]
#!/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
Code: [Select]
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

Offline aris

  • Newbie
  • *
  • Posts: 49
Re: rsync wont start on schedule and boolocal
« Reply #3 on: July 27, 2019, 07:51:44 AM »
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
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

Code: [Select]
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
)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: rsync wont start on schedule and boolocal
« Reply #4 on: July 27, 2019, 08:17:06 AM »
Hi aris
Show us your  bootlocal  file.

Offline aris

  • Newbie
  • *
  • Posts: 49
Re: rsync wont start on schedule and boolocal
« Reply #5 on: July 29, 2019, 06:18:48 AM »
Hi Rich
Code: [Select]
#!/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

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: rsync wont start on schedule and boolocal
« Reply #6 on: July 29, 2019, 07:25:43 AM »
Hi aris
Try changing this:
Code: [Select]
/usr/sbin/crondto this:
Code: [Select]
/usr/sbin/crond -S -l 0 -L /home/$USER/crond.logThat's a lowercase  L  and  zero  after the  -S.  You can find out what these switches mean with this command:
Code: [Select]
crond --helpNow 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.

Offline aris

  • Newbie
  • *
  • Posts: 49
Re: rsync wont start on schedule and boolocal
« Reply #7 on: July 29, 2019, 11:22:04 PM »
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
Code: [Select]
#!/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
Code: [Select]
#!/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 ?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: rsync wont start on schedule and boolocal
« Reply #8 on: July 30, 2019, 07:03:42 AM »
Hi aris
Try to see what  /home/tc/cpdr33.sh  is doing:
Code: [Select]
#!/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 &

Offline aris

  • Newbie
  • *
  • Posts: 49
Re: rsync wont start on schedule and boolocal
« Reply #9 on: July 30, 2019, 08:07:53 PM »
Hi Rich..still log no output
Code: [Select]
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
Code: [Select]
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)
....

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: rsync wont start on schedule and boolocal
« Reply #10 on: July 30, 2019, 08:32:38 PM »
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:
Code: [Select]
ps aux | grep bootlocal

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: rsync wont start on schedule and boolocal
« Reply #11 on: July 30, 2019, 08:36:56 PM »
Hi aris
One more thought. Did you remember to make  /home/tc/cpdr33.sh  executable?
Code: [Select]
chmod 774 cpdr33.sh

Offline aris

  • Newbie
  • *
  • Posts: 49
Re: rsync wont start on schedule and boolocal
« Reply #12 on: July 30, 2019, 08:40:06 PM »
That suggests that  /home/tc/cpdr33.sh  is not being started from  bootlocal.sh. Does this return anything:
Code: [Select]
ps aux | grep bootlocal
nope
Code: [Select]
tc@box:~$ ps aux | grep bootlocal
 2979 tc       grep bootlocal

its 775
Code: [Select]
  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
« Last Edit: July 30, 2019, 08:44:14 PM by aris »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: rsync wont start on schedule and boolocal
« Reply #13 on: July 30, 2019, 08:47:22 PM »
Hi aris
I'm starting to run out of ideas. If you add a  -x  to the first line in your script like this:
Code: [Select]
#!/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:
Code: [Select]
./cpdr33.shwhat do you get?

Offline aris

  • Newbie
  • *
  • Posts: 49
Re: rsync wont start on schedule and boolocal
« Reply #14 on: July 30, 2019, 09:01:07 PM »
Code: [Select]
sh /home/tc/cpdr33.sh
/home/tc/cpdr33.sh: line 9: syntax error: unterminated quoted string
and line 9 is
Code: [Select]
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
Code: [Select]
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

« Last Edit: July 30, 2019, 09:16:35 PM by aris »