Jump to content

A crontab question


Vdubjunkie
 Share

Recommended Posts

I've managed to configure two machines as NIS master/slave and Samba PDC/BDC. This was quite an accomplishment for me.. alright, I won't wait around for the pats on the back.. I've given them to myself..

 

My dillema is this. It is suggested to utilize cron/crontab to sync the /etc/samba/ files. That is fine, I even wrote up a working script. (first useful script I've written in linux) I'll list my syntax below:

 

/usr/bin/rsync -avz --exclude '*.SID' --exclude '*.example' --exclude '*.tdb' -e ssh /etc/samba/ MedusaII:/etc/samba/

The first problem I have here is that it wants a password when I run this. Not too useful for unattended cron utilization I think.

 

The other thing is that I was unsuccessful using the --exclude-from option. If maybe you could help with that syntax. Basically my file was like this:

 

'*.SID' '*.example'

 

Any help is mucho appreciated.

:twisted:

Link to comment
Share on other sites

wild idea:

 

if the script needs the password then the sudo package might help you since i seem to recall that crontab can run a task under a certain user. you can create a dummy user and let sudo allow that user to do the task with root level authority without using a password.

 

regarding the syntax, ill leave that to other people who excels in this stuff as im running a little bit out of time. (look for aru, he's a nut at this) :mystismiles:

 

ciao!

Link to comment
Share on other sites

another idea could be the use of 'expect' to write the password automatically

 

---ramfree!!! that icon scares me a lot!!!! please don't use it

 

about the syntax, don't use quotes at all (notice that I don't have any idea about rsync but bash doesn't expand the "*" whithin quotes in that context)

Link to comment
Share on other sites

/usr/bin/rsync -avz --exclude '*.SID' --exclude '*.example' --exclude '*.tdb' -e ssh /etc/samba/ MedusaII:/etc/samba/

 

I insist in that I have no idea of rsync, but I trust you and I believe that the commands are right, so this should work:

 

/usr/bin/rsync -avz --exclude *.{SID,example,tdb} -e ssh /etc/samba/ MedusaII:/etc/samba/

 

about the password, since rsync seems to use ssh and ssh can be configured to run w/o password, you might want to look for that

 

sorry for the repost, but my connection sucks right now

Link to comment
Share on other sites

expect? is that a bash command/function? i dont have a linux machine so i cannot check.

 

not use it after i have petitioned it for so long? you are really nuts and i dont listen to the whimperings of a nut. :mystismiles:

 

but i have to admit that nuts are very useful. look im learning another new linux thing from a nut. :mystilol:

 

ciao!

Link to comment
Share on other sites

expect? is that a bash command/function? i dont have a linux machine so i cannot check.
No, it is a program that allows automatic dialogue with interactive programs. Very useful, for example, to automate a web site (i.e. at lycos) through ftp

 

not use it after i have petitioned it for so long? you are really nuts and i dont listen to the whimperings of a nut. :mystismiles:

but i have to admit that nuts are very useful. look im learning another new linux thing from a nut. :mystilol:

ciao!

Don't tell me that you prefer such mounstruosity than this cute icon --> :mrgreen:

 

a nut :P

Link to comment
Share on other sites

forget all that I said about the syntax before, rsync excludes need quotes to protect the regexp from bash expansion... so I guess that your syntax is OK.

I've been playing a lot this evening with rsync -- a great app -- and I've made a couple of cron scripts to synchronize a few directories between my two machines. Basically I've followed the man page.

No need for password at all! (accordingly to my ssh configuration).

 

basically my scripts are using this function:

sincronizar () {



    [ $# != 2 ] && return 1

    local="${1}/"

    remoto="arusabal@mdkhost:${2}/"

    command="rsync -avuzb --exclude '*~'"



    $command $local $remoto

    $command $remoto $local

}



sincronizar local_dir remote_dir

 

thanks for showing me the posibilities of rsync :D

hth :D

 

PS: set the env variable RSYNC_RSH=ssh in your .bash_profile

Link to comment
Share on other sites

thanks for showing me the posibilities of rsync 

hth 

 

Rsync is quite a little prog. Glad I could have been the one to plant the seed there.

 

In turn, thanks for turning me on to the "proper" config for ssh. For those freaks out there as thrilled by this idea as me, here is a very good site to visit for step by step on setting this up.

 

http://cwrulug.cwru.edu/docs/ssh-agent.html

If like me, your ssh protocol prefers to run v2, you will need to create the file ~/.ssh/authorized_keys2 instead of authorized_keys. If your not sure, heck have both files. It worked for me.

 

aru.. I may be hitting you up again w/ scripting/coding, etc. questions as it is becoming very apparent those skills will be necessary to be a true "power user" in nix.

 

Thanks again. :twisted:

Link to comment
Share on other sites

aru..  I may be hitting you up again w/ scripting/coding, etc. questions as it is becoming very apparent those skills will be necessary to be a true "power user" in nix.

 

Thanks again. :twisted:

 

You are very wellcome. I'll try to help you as much as I can :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...