- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: how to configure crontab ?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 12:07 AM
тАО03-05-2009 12:07 AM
I have configured crontab on one server, to run the scripts(all of the scripts are placed under /root/bin/ directory)
question
1, is there an automated way to configure the crontab on rest of the 69 servers ?
e.g we can copy /etc/sudoers configured on 1 machine to other machines .. I mean is there any way to configure the crontab too ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 12:25 AM
тАО03-05-2009 12:25 AM
Re: how to configure crontab ?
Problem with this is that crontab -l or -e won't show them (if i remember correctly).
If you want to use this just edit a file like /etc/crontab and write normal crontab procedures. Then run
# crontab /etc/crontab
Best regards
Fredrik Eriksson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 02:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 04:14 AM
тАО03-05-2009 04:14 AM
Re: how to configure crontab ?
# crontab crontab-file
> If you want to use this just edit a file like /etc/crontab and write normal crontab > procedures. Then run
> # crontab /etc/crontab
yes the above solution works :)
> Problem with this is that crontab -l or -e won't show them (if > i remember correctly).
No, atleast the distro(SUSE) I am using works just apposite to what you said
in case of
# crontab /path/to/file
what happens is that it overwrites the root's crontab (/var/spool/cron/tabs/root)
and 'crontab -l' and 'crontab -e' shows all the jobs in /path/to/file
Thanks Dear Vitaly Karasik
your suggestion also works ;).
the only difference I found is the path(it might be due to the distro difference).
On my box(SUSE 10 SP2) its inside /var/spool/cron/tabs directory
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 11:47 PM
тАО03-05-2009 11:47 PM
Re: how to configure crontab ?
However, with such number of servers I would see problematic to maintain script up to date according latest changes/requirements.
What I would do is that I would export some shared folder from one of the servers (where crontabfile would be placed) and mounted it e.g. via NFS on the rest of the servers. this way you always have one copy of the script available on all the servers
Now it depends, whether all of your servers should have just the same (shared) crontab file or there can be slight differencies. if they are the same, you may want just to link root's crontab (/var/spool/cron/root) to your NFS-shared crontabfile. If there might be differencies you need to write short script that will compile together your central NFS shared crontabfile and local one and install it after every change of either central or local script.
emha.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2009 12:27 PM
тАО03-08-2009 12:27 PM
Re: how to configure crontab ?
Directly changing the file /var/spool/cron/root may or may not work. On HP-UX, cron needs to be notified of any changes, otherwise they would be ignored.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2009 03:00 PM
тАО03-08-2009 03:00 PM
Re: how to configure crontab ?
However, question is posted in linux forum ans there is SUSE distro mentioned above.
Here is what cron daemon man page on my SUSE 7.3 box says:
----
Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be
restarted whenever a crontab file is modified.
----
similar statement I have found in RHEL AS4 man page.
so, to satisfy cron, it may be necessary to update timestamps of mentioned folders somehow (if SUSE 10.2 still relys on folder timestamps), but there is still advantage of having one central crontab file
emha.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2009 11:15 PM
тАО03-08-2009 11:15 PM
Re: how to configure crontab ?
> However, with such number of servers I would see problematic to
> maintain script up to date according latest changes/requirements.
Yes I have done the following setup
on a server I have configured rsync
on rsync server(192.168.0.6) I placed all the scripts under the /root/bin/scripts directory
and
under /root/bin/cron directory, I created a file 'root' that contains cron jobs
# cat /etc/rsyncd.conf
[scripts]
path = /root/bin/scripts
[cron-jobs]
path = /root/bin/cron
----
I then created a script, that will configure the cron jobs on all 69 servers.
#!/bin/bash
while [ 1 != 0 ]; do
clear
echo -e "\nTo quit, press CTRL+C\n"
echo -e "Please Enter the IP: "
read IP
ssh -v "$IP" "echo -e '*/1 * * * * /usr/bin/rsync -av 192.168.0.6::scripts /root/bin' >> /var/spool/cron/tabs/root"
ssh -v "$IP" "echo -e '*/1 * * * * /usr/bin/rsync -av 192.168.0.6::cron-jobs /var/spool/cron/tabs' >> /var/spool/cron/tabs/root"
if [ "$?" == "0" ]
then echo "$IP on "$(date '+%d-%m-%Y')" crontab configured properly .... OK" >> /root/Servers_Done.log
else echo "$IP on "$(date '+%d-%m-%Y')" crontab not configured .... failed" >> /root/Servers_Failed.log
fi
done
and the above is working
the only thing that doesnt seems to work is
#ssh -v "$IP" "echo -e '*/1 * * * * /usr/bin/rsync -av 192.168.0.6::scripts /root/bin' >> /var/spool/cron/tabs/root" && "echo -e '*/1 * * * * /usr/bin/rsync -av 192.168.0.6::cron-jobs /var/spool/cron/tabs' >> /var/spool/cron/tabs/root"
i.e if I use "&&"(instead of using ssh two times), then I got the following error
test.sh: line 9: echo -e '*/1 * * * * /usr/bin/rsync -av 192.168.0.6::cron-jobs /var/spool/cron/tabs' >> /var/spool/cron/tabs/root: No such file or directory
please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 01:23 AM
тАО03-09-2009 01:23 AM
Re: how to configure crontab ?
ssh -v "$IP" "echo -e '*/1 * * * * /usr/bin/rsync -av 192.168.0.6::scripts /root/bin' >> /var/spool/cron/tabs/root && echo -e '*/1 * * * * /usr/bin/rsync -av 192.168.0.6::cron-jobs /var/spool/cron/tabs' >> /var/spool/cron/tabs/root"
i.e following cause error:
ssh -v $IP "....." && "...."
and following works
ssh -v "$IP" "..... && ...."
DONE ;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 06:45 AM
тАО03-09-2009 06:45 AM
Re: how to configure crontab ?
Ref: http://jobscheduler.sourceforge.net/