I'm managing about 28 servers at the moment, a developer came up to me this morning telling me his machine was more then one minute late. Auch, embarrassing situation here I thought. Did I do something wrong? All servers are synced with ntpd on the same central timeserver. How can it be that one server is way off? Digging the internet on so called experts didn't help much, most use ntpd and are done. So why is the server off?
Well it seems when a server is off too much on boot time, ntpd will just not work anymore. That was a new for me. The catch is that servers don't sync on boot with ntp, they sync with the hwclock. If the clock is way off a certain threshold ntp will just silently fail.
How can I fix the problem so the server will boot, set time correct and keep it correct?
Open your /etc/rc.local file and add ntpdate to it (use any time server you want), then sync the hwclock:
# sync time
ntpdate -sb pool.ntp.org
hwclock --systohc
Now after boot, sysinit is run, then rc.local, the time is updated, the hwclock is synced, then the services in rc.d will start. Because we still use ntpd the server time will stay in sync till next reboot; where it is synced on boot et cetera.
Tnx to:
http://nuclearfusionreactor.blogspot.nl/
http://www.rgrjr.com/linux/ntp.html#ntpdate-boot
Tuesday, 15 October 2013
Wednesday, 29 May 2013
Shrink your VirtualBox disk
After working in my VirtualBox RedHat installation my disk grew to 27Mb. I want to make is smaller so it can fit on the left over space of my 5.6Mb SSD.
Fill the disk with 0's and delete the zero file:
Fill the disk with 0's and delete the zero file:
$ dd if=/dev/zero of=~/delete.me $ rm ~/delete.me Start the Virtial Box Manager and fix the disk:
|
Monday, 26 November 2012
Trap, thread and monitor
I just want to dump three great resources for bash hacking. First of all a list with some handy resources. Second if about making your script aware of the ctrl-z combo and third a bash script that spawns a couple of threads.
1. http://bash.cyberciti.biz/shell/monitoring/
2. http://hacktux.com/bash/control/c
3. http://blog.apokalyptik.com/2008/12/11/using-wait-and-for-threading-in-bash/
It certainly helped me monitoring some disc space usage during an installation.
1. http://bash.cyberciti.biz/shell/monitoring/
2. http://hacktux.com/bash/control/c
3. http://blog.apokalyptik.com/2008/12/11/using-wait-and-for-threading-in-bash/
It certainly helped me monitoring some disc space usage during an installation.
Wednesday, 3 October 2012
Redirect bash output to file and screen
So you have made a nice new script in bash. Fancy you! Alas it has to log to a file and to screen. That might sounds simple, and it is, check this out:
exec > >(tee ${LOGFILE}) 2>&1
WTH? Well just redirect all output (error and out) to a subprocess which tee's it (write to screen and to log).
exec > >(tee ${LOGFILE}) 2>&1
WTH? Well just redirect all output (error and out) to a subprocess which tee's it (write to screen and to log).
Use WLST functions inside Jython classes
Using WLST can be frustrated because all of the global functions that seemingly cannot be used inside classes. Putting functions in classes and making re-usable libraries is common practice in the current development world. Most developers would like to avoid spagetti-monsters; although some still seems to like the idea of spagetti with tomato sauce.
To use the global commands of WebLogic's WLST import the correct module:
import wlstModule as wlst
wlst.connect('weblogic','welcome1','t3s://localhost:7002')
wlst.redirect('/var/log/weblogic.log')
Thanks to: http://stackoverflow.com/questions/8252846/wlstmodule-connection-information-lost
To use the global commands of WebLogic's WLST import the correct module:
import wlstModule as wlst
wlst.connect('weblogic','welcome1','t3s://localhost:7002')
wlst.redirect('/var/log/weblogic.log')
Thanks to: http://stackoverflow.com/questions/8252846/wlstmodule-connection-information-lost
Tuesday, 2 October 2012
Remove files older then X days on Linux
I always forget how i can clean up my /var/log. Therefor i dump the code snippet i need to do this. And it is so very simple...
Delete all files older then 3 days in current and child directories:
find . -mtime +3 -exec rm -rf {} \;
Delete all files older then 3 days in current and child directories:
find . -mtime +3 -exec rm -rf {} \;
Friday, 14 September 2012
PC speaker beep is so annoying
When working on a linux machine and tabbing out your commands, it often happens that you hear the speaker beep. This can be very annoying. So let's turn it off. Remove the pc speaker modules "pcspkr" and "snd_pcsp". You might have only one of these modules in use, but they both enable beeps.
Open a terminal and issue this command as root:
# modprobe -r pcspkr snd_pcsp
To prevent the "pcspkr" and "snd_pcsp" modules from loading again at startup add them to modprobe's blacklist in /etc/modprobe.d/blacklist. You can do this with the following command:
# vi/etc/modprobe.d/blacklist
blacklist pcspkr
blacklist snd_pcsp
See: http://www.thinkwiki.org/wiki/How_to_disable_the_pc_speaker_(beep!)
Open a terminal and issue this command as root:
# modprobe -r pcspkr snd_pcsp
To prevent the "pcspkr" and "snd_pcsp" modules from loading again at startup add them to modprobe's blacklist in /etc/modprobe.d/blacklist. You can do this with the following command:
# vi
blacklist pcspkr
blacklist snd_pcsp
See: http://www.thinkwiki.org/wiki/How_to_disable_the_pc_speaker_(beep!)
Subscribe to:
Posts (Atom)