Narisa.com: nohup: สั่งโปรแกรมทำงานต่อ - Narisa.com

Jump to content

Subscribe to Patrickz's Blog        RSS Feed

nohup: สั่งโปรแกรมทำงานต่อ

Leave Comment
ไม่ได้ใช้คำสั่งนี้นานๆ ลืมได้เหมือนกัน ทั้งที่เป็นคำสั่งง่ายๆ เลยเขียน blog นี้ลงโทษตัวเองที่ลืม
เคยไหม เวลาเข้า ssh แล้วต้องรัน scripts ซึ่งต้องใช้เวลานานๆ แต่เน็ตดันหลุด (และมักจะหลุดตอนมีเหตุสำคัญ...)

Linux มีคำสั่ง run command เป็นแบบ background process ดังนี้

$command &

ถ้าหากเรา remote ด้วย SSH, Telnet แล้วใช้คำสั่งนี้ เวลาเราออกจาก ssh/telnet ไม่ว่าจะเน็ตหลุดหรือไม่ตั้งใจก็ตาม
คำสั่งที่ทำงานอยู่จะถูก kill process ไปด้วย

ดังนั้น Linux จึงมีคำสั่ง nohup ใช้งานดังนี้

$nohup command &

note:
  • HUP ย่อมาจาก hangup (signal)
  • no hup คือ การไม่ส่ง hangup signal ไปยัง kernel
  • ไม่จำเป็นต้องใช้ nohup กับ wget เนื่องจาก wget มี wget -b อยู่แล้ว
Links
keyword: Linux, long, background, process

0 Comments On This Entry

 

September 2010

S M T W T F S
   1234
5678910 11
12131415161718
19202122232425
2627282930  

Search My Blog

Recent Comments

test

test