General NAS-Central Forums

Welcome to the NAS community
It is currently Thu Apr 27, 2017 1:23 am

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Crontab problem
PostPosted: Sat Jun 23, 2012 6:18 pm 
Offline

Joined: Mon Oct 03, 2011 3:07 pm
Posts: 18
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?


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Tue Jun 26, 2012 10:15 am 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 5981
Does crontab work at all? How did you add the line?


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Tue Jun 26, 2012 1:54 pm 
Offline

Joined: Mon Oct 03, 2011 3:07 pm
Posts: 18
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.


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Tue Jun 26, 2012 2:13 pm 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 5981
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.


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Tue Jun 26, 2012 2:51 pm 
Offline

Joined: Mon Oct 03, 2011 3:07 pm
Posts: 18
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-


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Tue Jun 26, 2012 3:26 pm 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 5981
Seems impossible to me. How can a 341 byte file contain the same text as a 606 byte file?


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Wed Jun 27, 2012 4:13 pm 
Offline

Joined: Mon Oct 03, 2011 3:07 pm
Posts: 18
You are totally right: i opened twice the same file :oops:

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'

And this is the CRONTAB-file
    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'


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Wed Jun 27, 2012 8:16 pm 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 5981
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:
Code:
#!/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"
Make it executable, and run it from cron.


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Wed Jun 27, 2012 9:30 pm 
Offline

Joined: Mon Oct 03, 2011 3:07 pm
Posts: 18
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:
Code:
#!/bin/sh
echo "JP1 gestart: $(date)" >> /tmp/mybackup.log

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?


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Thu Jun 28, 2012 9:17 am 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 5981
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).


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Thu Jun 28, 2012 8:27 pm 
Offline

Joined: Mon Oct 03, 2011 3:07 pm
Posts: 18
At the moment i have this testscript working:
Code:
#!/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 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.


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Thu Jun 28, 2012 9:01 pm 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 5981
Puffeltje wrote:
the 4th line with the SSH-command won't execute
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.
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.


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Sun Jul 01, 2012 8:05 pm 
Offline

Joined: Mon Oct 03, 2011 3:07 pm
Posts: 18
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?


Top
 Profile  
 
 Post subject: Re: Crontab problem
PostPosted: Mon Jul 02, 2012 8:53 am 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 5981
Puffeltje wrote:
Is it enough to uncomment the line '# FFPSYMLINK=1' in after_booting.sh or must i made more changes to that file?
That should be sufficient. But you'll have to provide the full path of ssh in crontab, e.g. /ffp/bin/ssh


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group