LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-07-2012, 06:18 AM   #1
Ajit Gunge
Member
 
Registered: Jan 2008
Location: Pune
Distribution: RHEL,fedora
Posts: 253
Blog Entries: 1

Rep: Reputation: 21
Question question regarding a cronjob?


Hi All,
I have a set of servers that are interconnected.I have recently modified a cronjob entry for one of the servers.I want the same entry to be copied in rest of the servers that are connected.Is there a way to do this without actually going to each server manually editing the crontab -e file and adding the entry.If yes how can I do this task.

Thanks,
Ajit
 
Old 05-07-2012, 06:30 AM   #2
em31amit
Member
 
Registered: Apr 2012
Location: /root
Distribution: Ubuntu, Redhat, Fedora, CentOS
Posts: 190

Rep: Reputation: 55
i guess no direct way to do, but this task can solve by creating a SHELL script and execute it all servers from a loop.
 
Old 05-07-2012, 06:46 AM   #3
the_gripmaster
Member
 
Registered: Jul 2004
Location: VIC, Australia
Distribution: RHEL, CentOS, Ubuntu Server, Ubuntu
Posts: 364

Rep: Reputation: 38
Quote:
Originally Posted by Ajit Gunge View Post
Hi All,
I have a set of servers that are interconnected.I have recently modified a cronjob entry for one of the servers.I want the same entry to be copied in rest of the servers that are connected.Is there a way to do this without actually going to each server manually editing the crontab -e file and adding the entry.If yes how can I do this task.

Thanks,
Ajit
There is an easy way to do this

For Ubuntu: Copy this file from the server where you added your cron job and place it in the other servers:

Code:
/var/spool/cron/crontabs/<username>
For Fedora/CentOS/Redhat:

Code:
/var/spool/cron/<username>
Take note of the permissions of the file.

Last edited by the_gripmaster; 05-07-2012 at 06:48 AM.
 
Old 05-07-2012, 02:54 PM   #4
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
For the perms specify the -p option. But some good things to look at here are MTPuTTY(Multi-Tabbed) and PuTTYCS(Command Sender). both of these will allow you to send the same command to all of your open ssh sessions without having to use screen or create ssh in a for loop.
 
Old 05-07-2012, 07:17 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Probably the copy n paste soln for a one off for a reasonable num (<10) servers.
Otherwise its worth building eg an ssh script for future use, or even adding a cfg engine like puppet.
 
Old 05-08-2012, 12:54 AM   #6
Ajit Gunge
Member
 
Registered: Jan 2008
Location: Pune
Distribution: RHEL,fedora
Posts: 253
Blog Entries: 1

Original Poster
Rep: Reputation: 21
Thank you all for all your valuable suggestions.
 
  


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
question regarding a cronjob? Ajit Gunge Linux - Software 3 05-03-2012 04:17 AM
cronjob doing it twice why? joesto Linux - Newbie 4 11-17-2010 03:36 PM
Cronjob / script question nazs Linux - General 1 12-21-2006 02:45 PM
cronjob help meeh Linux - General 1 03-26-2004 12:41 PM
Cronjob question jungsonn Linux - Newbie 3 03-22-2003 10:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:17 PM.

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