วันพุธที่ 11 มกราคม พ.ศ. 2555

เมื่อใช้ xcopy แล้ว nsufficient-memory นี่เลยครับ robocopy

Here is an interesting issue I ran into today. I have a script which creates a local copy of one of the important folders on the server using the xcopy command. To make the long story short, after several “accidents” with people messing up or deleting files on the server, we figured that letting people to make local mirrors on their own desktops might be slightly better than restoring stuff back from the tape 4 times a day.

It was something along the lines of:

rmdir /S /Q "%HOMEPATH%\My Documents\Important"
xcopy /E /R /Y /I G:\Important "%HOMEPATH%\My Documents\Important"

The script worked fine for almost a year now. Today however it decided to fail. After copying 1 or 2 folders it would simply stop. After closer inspection of the output I noticed that the last line was:

Insufficient Memory

I immediately checked the memory. The machine had 512 MB of RAM, and over 20 GB of free disk space. The folder I was attempting to copy had only 128 MB. This could not be correct.

Quick google confirmed this – the “insufficient memory” message is very misleading. It appears that this message shows up when the fully qualified (ie. with path) name of the copied file is longer than 254 characters which seems to be Windows maximum path length. Yes – even in WinXP SP2 and Win 2k3. Thank you Microsoft!

So I’m guessing the message doesn’t really refer to the actual free memory, but to the amount of space left in the file name buffer… Or at least I hope that’s what it means. Either that or MS just decided to make “insufficient memory” one of those lovely have a “catch all exceptions and errors here” clauses.

There are essentially 3 workarounds to this:

1.fix your paths – you can try using virtual drives, junctions and all that jazz to make the source and destination paths shorter. Still, this does not mean that a trigger happy user won’t build a crazy long directory tree in your important folder in the future
2.Use xxcopy – a 3rd party xcopy clone. It was suggested by David at blogdom.org. This actually worked for me but I’m not entirely happy with this solution. The good part is that xxcopy implements almost all the regular xcopy switches. The bad part is that to use it for commercial purposes you are supposed to pay up $20 or more.
3.Use robocopy – which seems to be the optimal solution. Robocopy is a part of Windows Server 2003 Resource Kit. The kit will only install on Windows XP and 2003 but robocopy will work on any NT compatible machine. Just install the kit on some machine and copy robocopy.exe from it to all the workstations that need it
The added benefit of using robocopy is that it actually simplified my script:

robocopy \\server\share\Important "%HOMEPATH%\My Documents\Important"

Robocopy can snag the copies directly from the network share, so I do not have to worry about having correct drive letters assigned to the correct shares. This was never really a problem for me since I use login scripts to mount shares on our network, but it is a good thing nevertheless.

In addition robocopy does true mirroring – it will purge all the files in the destination folder which do not appear in the source, saving me the headache of deleting the whole folder prior to copying.

In conclusion – xxcopy works, but robocopy works better. Get it and use it.

[tags]xcopy, xcopy insufficient memory, insufficient memory, xxcopy, robocopy, windows[/tags]

 ที่มา
http://www.terminally-incoherent.com/blog/2007/02/05/xcopy-insufficient-memory/

วันพุธที่ 7 ธันวาคม พ.ศ. 2554

การสร้างสัมมาสติ

การเจริญวิปัสนา เป็นสิ่งที่เราทุกๆคนได้ทำกันอยู่แล้ว แต่ไม่มากนัก เพราะทุกคนต้องมีสติ แต่สติที่มีอยู่จะได้ถูกพัฒนาขึ้นเป็นมหาสติ ต้องมีการทำอย่างต่อเนื่อง เพื่อให้มีความมั่นคงในสติของตัวเรา
ดังนั้นการเจริญสติจึงเป็นหัวใจที่ทำให้เราสามารถที่จะเข้าไปถึงนิพพานทีละนิดๆ สะสมทุกๆวันไปเรื่อยๆจนกว่าจะได้ในชาติใหนก็ตาม...

วันอังคารที่ 6 ธันวาคม พ.ศ. 2554

การรักษาใจแบบ 90/10
ความจริงแล้วทุกๆวันไม่ว่าเราจะทำอะไรก็ตาม เราสามารถทำให้เราสุขหรือทุกข์ได้ตามที่ต้องการ คุณว่าใหม 90% เราสามารถควบคุมได้ แต่อีก 10% ก็อาจจะมาจากปัจจัยภายนอกที่ไม่สามารถจัดการได้ เช่นรถไฟมาไม่ตรงตามเวลาที่เราต้องการ เป็นต้น

มาดูเหตุการณ์ตัวอย่างกันดีกว่า ผมกำลังจะไปทำงานนั่งดื่มกาแฟอย่างสบายอารมณ์ ลูกชายตัวดีวิ่งเล่นมาโดนกาแฟเข้าทำให้กาแฟหกใส่เสื้อทำงาน ผมอารมณ์เสียทันที(ใจเสียไปแล้ว) ต่อว่าลูกไปใหญ่ลูกก็เสียใจแถมต่อว่าภรรยาที่ไม่ดูแลลูกด้วย(โดนอีก) ต้องขึ้นไปเปลี่ยนเสื้อใหม่ หลังจากนั้นก็ขับรถไปส่งลูกไปโรงเรียนทั้งที่อารมณ์เสีย ขับรถด้วยความเร็วเกินกำหนดโดนตำรวจออกใบสั่ง ทำให้ไปส่งลูกช้าไปอีก พอถึงโรงเรียนลูกก็ออกจากรถไปโดยไม่เคารพพ่อ สรุปคือ เหตุการณ์เดียวคือ กาแฟหก(10%) แต่ทำให้เหตุการณ์ต่างๆ(90%) เกิดขึ้นจากตัวเราแท้ๆอย่างเดียว

ในทางกลับกันถ้ากาแฟหก(10%) แล้วเราก็เตือนลูกว่าให้ระวังหน่อย แล้วก็ทิ้งอารมณ์นั้นไว้ตรงนั้นก็จะทำให้การดำเนินชีวิตปกติ(90%) เหมือนเดิม ขับรถไปส่งด้วยใจปกติไม่โดนตำรวจจับ ส่งลูกเข้าโรงเรียนได้ทัน ทุกคนก็จะมีความสุขร่วมกัน

วิปัสนาคือเห็นตามความจริงในรูปแบบนี้ละครับ เห็นแล้วก็ดับไปตามกฏไตรลักษณ์ จะไปยึดมั่นถือมั่นอะไรมากไม่ได้นั่นเอง


วันจันทร์ที่ 17 ตุลาคม พ.ศ. 2554

การ remove connection เก่าบน windows

1) Open the “Start” menu and choose “Run…”
2) Type in “cmd” (without the quotes) and click “ok”.
3) At the cmd prompt, type in “set devmgr_show_nonpresent_devices=1″ (without the quotes) and press enter. (Note that nothing seems to happen–this is ok. We are actually setting an environment variable which is going to help us to see hidden devices)
4) On the next cmd prompt line, type in “devmgmt.msc” (without the quotes) and press enter. This will launch the Windows Device Manager Console.
5) In the Device Manager Console, from the “View” menu, select “Show Hidden Devices”

http://www.tech-recipes.com/rx/504/how-to-uninstall-hidden-devices-drivers-and-services/

วันศุกร์ที่ 27 พฤษภาคม พ.ศ. 2554

การ setup cisco switch ให้เป็น Server+Client mode

การเซ็ต VLAN , VLAN Trunking และ VTP Domain บน Cisco Catalyst 2960 (Layer2) และ 3560 (Layer3)

จุดประสงค์ต้องการเซ็ต Switch เป็น VLAN โดยใช้ 3560 เป็น Core Switch และ 2960 กระจายไปตามจุดต่างๆในเครือข่าย

สิ่งที่ต้องทำคือ

- เปิด VTP ขึ้นมา ตั้งชื่อว่า VTPNAME

- กำหนด VTP บน 3560 เป็น Server Mode

- กำหนด VTP บน 2960 เป็น Client Mode

- ใช้ VTP Version 2

- สาย LAN เชื่อมระหว่าง Switch ใช้ Port 1 โดยทำเป็น Trunking Mode 802.1q

- SW ทุกตัวตั้งค่า VLAN ดังนี้

Port 2-5 VLAN 100 , MAIN

Port 6-10 VLAN 200 , FRONT



เริ่ม

บน 3560

switch#conf t

switch(config)#hostname SW_Core

SW_Core(config)#end

SW_Core#

SW_Core#conf t

SW_Core(config)#vtp domain VTPNAME

SW_Core(config)#vtp mode server

SW_Core(config)#end



บน 2960

คำคล้ายกันแต่เปลี่ยน hostname เป็นชื่ออื่น และ vtp mode เป็น client



ตรวจสอบ VTP โดยคำสั่ง

SW_Core#sh vtp status

ดู version ว่าเป็น v 2 หรือไม่ หากไม่เซ็ตดังนี้

Console>(enable)set vtp v2 enable



เซ็ต trunking ที่ Port 1 ของทุกๆ Switch

SW_Core#conf t

SW_Core(config)#interface fastEthernet 0/1

SW_Core(config-if)#switchport trunk encapsulation dot1q

SW_Core(config-if)#switchport mode trunk

SW_Core(config-if)#end



หากต้องการดูสถานะหลัง config

#sh interfaces fa0/1 switchport



เซ็ต VLAN

Name VLAN

———————————

Switch#conf t

Switch#vlan 100

Switch#name MAIN

Switch#exit

Switch#vlan 200

Switch#name front

Switch#exit



Add port to VLAN

———————————

Switch#config terminal

Switch#interface range fa0/2-5

Switch#switchport mode access

Switch#switch access vlan 100

Switch#exit

Switch#interface range fa0/6-10

Switch#switchport mode access

Switch#switch access vlan 200

Switch#exit


SW_Core#sh vlan <== ดูสถานะของ VLAN

Credit :
http://www.wandee.org/wordpress/?cat=12

วันจันทร์ที่ 9 พฤษภาคม พ.ศ. 2554

การ update image switch cisco 2960 ผ่าน xmodem

หา image file รอไว้ก่อนแล้วเข้าไปที่ prompt
switch: copy xmodem:[name file] flash:/dir/[name file]
แล้วไปทำการ start xmodem upload ที่ menu ได้เลย

วันพฤหัสบดีที่ 9 ธันวาคม พ.ศ. 2553

การเชื่อมต่อ mysql ข้ามเครื่อง

จริงๆก็ไม่ได้ยากอะไร แต่ตอนหา solution ก็นานเหลือเกิน
แก้ file my.cnf
ใส่ # ที่ bind ip 127.0.0.1 เพื่อให้ไม่ต้อง lock เครื่องที่เข้ามา แต่ก็อันตรายเหมือนกัน
แล้วก็ grant database ให้ remote machine เข้ามาได้ เช่น user@x.x.x.x เป็นต้น
เสร็จแล้วครับ

Download เอกสารต่างๆ

  VM Ware Doc