LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-28-2013, 03:49 PM   #1
allanm78
LQ Newbie
 
Registered: May 2013
Posts: 10

Rep: Reputation: Disabled
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.
 
Old 05-28-2013, 04:16 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,661

Rep: Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256
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.
 
Old 05-28-2013, 04:19 PM   #3
allanm78
LQ Newbie
 
Registered: May 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Hi!

I dont have sshkeyless setup on hundreds of hosts.

Do need expect script to work for now.

Thanks,
Allan.
 
Old 05-28-2013, 04:30 PM   #4
allanm78
LQ Newbie
 
Registered: May 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
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)
 
Old 05-28-2013, 07:49 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,661

Rep: Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256
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.

Last edited by jpollard; 05-28-2013 at 07:51 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect script: how do i send function key F12 in an expect script alix123 Programming 4 09-01-2013 09:06 PM
[SOLVED] /usr/bin/expect : Script to check server load using both expect and bash Soji Antony Programming 1 07-27-2010 11:27 PM
Expect Script not getting called in the Cron Job athreyavc Programming 3 11-10-2008 06:35 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron job for expect script ruchitadesai Programming 9 05-27-2005 04:34 AM


All times are GMT -5. The time now is 01:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration