LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Expect script for pushing out cron (https://www.linuxquestions.org/questions/linux-newbie-8/expect-script-for-pushing-out-cron-4175463825/)

allanm78 05-28-2013 03:49 PM

Expect script for pushing out cron
 
Hi!



I am in need of an expect script to update cron on multiple hosts. Expect is installed on the system and I am hoping if someone has a handy script already, to update cron on multiple hosts from an admin host, please share.



Thanks,
Allan.

jpollard 05-28-2013 04:16 PM

You shouldn't need an expect script. Just setup public key authentication for ssh.

Then you can just do "cat new-cron-file | ssh <remote> crontab"

IF you are dealing with a cluster, use the cluster tools to distribute the update.

allanm78 05-28-2013 04:19 PM

Hi!

I dont have sshkeyless setup on hundreds of hosts.

Do need expect script to work for now.

Thanks,
Allan.

allanm78 05-28-2013 04:30 PM

for j in `cat host-list`
do
expect -f /tmp/sshlogin.expect
done

can't read "j": no such variable
while executing
"spawn ssh -n username@$j 'crontab -l | tee /tmp/info'"
(file "/tmp/sshlogin.expect" line 2)

jpollard 05-28-2013 07:49 PM

I think you will have to export j to make it available in the environment.

Putting a public key on each system is safer than embedding a script with your password.


All times are GMT -5. The time now is 03:41 PM.