LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   question regarding a cronjob? (https://www.linuxquestions.org/questions/linux-newbie-8/question-regarding-a-cronjob-943647/)

Ajit Gunge 05-07-2012 05:18 AM

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

em31amit 05-07-2012 05:30 AM

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.

the_gripmaster 05-07-2012 05:46 AM

Quote:

Originally Posted by Ajit Gunge (Post 4672236)
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.

Kustom42 05-07-2012 01:54 PM

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.

chrism01 05-07-2012 06:17 PM

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.

Ajit Gunge 05-07-2012 11:54 PM

Thank you all for all your valuable suggestions.


All times are GMT -5. The time now is 11:34 PM.