Crontab problem
Crontab problem
i can't get crontab to work the way i want.
in the CLI (PuTTY) i can give the command:
/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/bin/mysqldump --opt --all-databases -pABCDE | gzip -c | ssh root@192.168.1.153 "cat > /testdump6.dmp"
After executing i see at the other NAS the file 'testdump6.dmp' in the rootdirectory.
When i put this command in crontab it looks like it isn't executed. For testing i let it execute every 2 minutes. This is my row in crontab:
*/2 * * * * /i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/bin/mysqldump --opt --all-databases -pABCDE | gzip -c | ssh root@192.168.1.153 "cat > /testdump6.dmp"
I also tried the command SCP in crontab to copy a file from the NSA210 to my other NAS but that also didn't execute.
Has anyone managed to send some files from NSA210 to another NAS with crontab?
in the CLI (PuTTY) i can give the command:
/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/bin/mysqldump --opt --all-databases -pABCDE | gzip -c | ssh root@192.168.1.153 "cat > /testdump6.dmp"
After executing i see at the other NAS the file 'testdump6.dmp' in the rootdirectory.
When i put this command in crontab it looks like it isn't executed. For testing i let it execute every 2 minutes. This is my row in crontab:
*/2 * * * * /i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/bin/mysqldump --opt --all-databases -pABCDE | gzip -c | ssh root@192.168.1.153 "cat > /testdump6.dmp"
I also tried the command SCP in crontab to copy a file from the NSA210 to my other NAS but that also didn't execute.
Has anyone managed to send some files from NSA210 to another NAS with crontab?
Re: Crontab problem
Does crontab work at all? How did you add the line?
Re: Crontab problem
yes, crontab works.
if i place "*/1 * * * * echo "CRONTAB opdracht uitgevoerd: $(date)" >> /tmp/mybackup.log" in crontab i see that the logfile is is changed every minute.
i added the line with VI. After added the line i checked with "crontab -l" to see if the new line is there.
if i place "*/1 * * * * echo "CRONTAB opdracht uitgevoerd: $(date)" >> /tmp/mybackup.log" in crontab i see that the logfile is is changed every minute.
i added the line with VI. After added the line i checked with "crontab -l" to see if the new line is there.
Re: Crontab problem
Then it must be an environment problem. I can imagine mysqldump needs '/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/bin:/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/sbin' in the PATH. (Well, actually /usr/local/zy-pkgs/bin and -/sbin, which is the same), and crond doesn't provide it.
Try a 'set >/tmp/set.dmp' in cron and from the commandline, and look at the differences.
Try a 'set >/tmp/set.dmp' in cron and from the commandline, and look at the differences.
Re: Crontab problem
I tried 'set >/tmp/set.dmp' from the CLI and from crontab. The text in the files are the same. The diverence is that the set.dmp from the CLI is 606 byte with rights rw-r--r--, and the set.dmp from crontab is 341 byte with rights rw-rw-rw-
Re: Crontab problem
Seems impossible to me. How can a 341 byte file contain the same text as a 606 byte file?
Re: Crontab problem
You are totally right: i opened twice the same file
This is the CLI-file:

This is the CLI-file:
- HISTFILE='/home/root/.ash_history'
HOME='/home/root'
IFS='
'
INPUTRC='/ffp/etc/inputrc'
LANG='en_US'
LD_LIBRARY_PATH='/i-data/62cc1e9a/.zyxel/zy-pkgs/lib'
LESS='-M'
LOGNAME='root'
MAIL='/var/mail/root'
OPTIND='1'
PATH='/ffp/sbin:/usr/sbin:/sbin:/ffp/bin:/usr/bin:/bin:/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/bin:/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/sbin'
PPID='31925'
PS1='\u@\h:\w\$ '
PS2='> '
PS4='+ '
PWD='/home/root'
SHELL='/ffp/bin/sh'
SSH_CLIENT='192.168.1.115 49562 22'
SSH_CONNECTION='192.168.1.115 49562 192.168.1.155 22'
SSH_TTY='/dev/pts/0'
TERM='xterm'
USER='root'
VISUAL='nano'
_='mysqldump'
- HOME='/root'
IFS='
'
LD_LIBRARY_PATH='/usr/local/zy-pkgs/lib'
MODEL_NAME='nsa210'
OLDPWD='/tmp/dev'
PATH='/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/zyxel/sbin:/usr/local/zy-pkgs/bin'
PPID='10374'
PS1='\w \$ '
PS2='> '
PS4='+ '
PWD='/root'
SHELL='/bin/sh'
TERM='vt102'
TZ=':/etc/localtime'
USER='root'
poweroutage='yes'
Re: Crontab problem
OK. I suppose you already saw that the CLI file has "/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/bin:/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/sbin" in the PATH, while the cron file doesn't.
I suggest you to create a script:Make it executable, and run it from cron.
I suggest you to create a script:
Code: Select all
#!/bin/sh
export PATH='/ffp/sbin:/usr/sbin:/sbin:/ffp/bin:/usr/bin:/bin:/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/bin:/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/sbin'
export LD_LIBRARY_PATH='/i-data/62cc1e9a/.zyxel/zy-pkgs/lib'
/i-data/62cc1e9a/.zyxel/zy-pkgs/mysql/bin/mysqldump --opt --all-databases -pABCDE | gzip -c | ssh root@192.168.1.153 "cat > /testdump6.dmp"
Re: Crontab problem
i think the script won't run from cron.
For a test i created a file 'jp1.sh' in the root.
in this file i have the following text:
in the CLI i execute 'chmod a+x /jp1.sh'
in crontab i created a line '*/1 * * * * /jp1.sh'
the file '/tmp/mybackup.log' isn't created by the script. is this the right way to test if the script is executed from cron?
For a test i created a file 'jp1.sh' in the root.
in this file i have the following text:
Code: Select all
#!/bin/sh
echo "JP1 gestart: $(date)" >> /tmp/mybackup.log
in crontab i created a line '*/1 * * * * /jp1.sh'
the file '/tmp/mybackup.log' isn't created by the script. is this the right way to test if the script is executed from cron?
Re: Crontab problem
From your environment dumps I understand that you are running FFP, while you're using firmware cron:
SHELL='/ffp/bin/sh'
SHELL='/bin/sh'
This probably means that FFP is chrooted (don't know if it can be run not-chrooted on a 210), and that means that FFP has a different root than cron has. So cron cannot find the script you put in FFP's root. (Unless you provide the relative path)
Use a directory which is the same in- and outside the chroot, like '/i-data/62cc1e9a/' (or better /i-data/md0, which is the same, but more portable).
SHELL='/ffp/bin/sh'
SHELL='/bin/sh'
This probably means that FFP is chrooted (don't know if it can be run not-chrooted on a 210), and that means that FFP has a different root than cron has. So cron cannot find the script you put in FFP's root. (Unless you provide the relative path)
Use a directory which is the same in- and outside the chroot, like '/i-data/62cc1e9a/' (or better /i-data/md0, which is the same, but more portable).
Re: Crontab problem
At the moment i have this testscript working:
the logfile is updated at the srart and end of the script.
the 4th line with the SSH-command won't execute
the 5th line execute as expected.
Code: Select all
#!/bin/sh
echo "JP1 gestart: $(date)" >> /i-data/md0/mybackup.log
export PATH='/ffp/sbin:/usr/sbin:/sbin:/ffp/bin:/usr/bin:/bin:/i-data/md0/.zyxel/zy-pkgs/mysql/bin'
export LD_LIBRARY_PATH='/i-data/md0/.zyxel/zy-pkgs/lib'
/i-data/md0/.zyxel/zy-pkgs/mysql/bin/mysqldump --opt --all-databases -pkameel01 | gzip -c | ssh root@192.168.1.153 "cat > /DataVolume/shares/FLIP/DB_BACKUP/testdump6.dmp"
/i-data/md0/.zyxel/zy-pkgs/mysql/bin/mysqldump --opt --all-databases -pkameel01 >/i-data/md0/BHK/alldb_`date +%Y-%m-%d_%H.%M.%S`.dmp
echo "JP1 gereed: $(date)" >> /i-data/md0/mybackup.log
the 4th line with the SSH-command won't execute
the 5th line execute as expected.
Re: Crontab problem
The script runs outside the FFP chroot, so the FFP ssh is by default not usable. Maybe the firmware has an ssh. You can add a "which ssh >> /i-data/md0/mybackup.log" to the script.Puffeltje wrote:the 4th line with the SSH-command won't execute
If the firmware doesn't have an ssh, you can edit after_booting.sh (in the root of the FFP chroot). In the header you can set a flag to create an /ffp symlink in the firmware root, then FFP ssh can be used (after rebooting), if you provide the full path.
Then there is a second issue, you'll have to provide an ssh key for loginless connecting, and you'll have to provide it outside the FFP chroot. Have a look in /ffp/etc/original/passwd to find out the home directory of root.
Re: Crontab problem
i think that the firmware of the nsa210 has no SSH. I put 'which ssh >> /i-data/md0/mybackup.log' in my test-script but it don't write a line in the log-file.
Is it enough to uncomment the line '# FFPSYMLINK=1' in after_booting.sh or must i made more changes to that file?
Is it enough to uncomment the line '# FFPSYMLINK=1' in after_booting.sh or must i made more changes to that file?
Re: Crontab problem
That should be sufficient. But you'll have to provide the full path of ssh in crontab, e.g. /ffp/bin/sshPuffeltje wrote:Is it enough to uncomment the line '# FFPSYMLINK=1' in after_booting.sh or must i made more changes to that file?